1. print()

출력함수.

Studio > 보기 > 출력 에 출력됨

ex ) print("Hello World!")

응용 : 여러개 문자열 연결

  사용문구 설명 예시
1 .. 문자열 연결 print("Hello ".."Laura")
2 /n 개행 출력 print("Hello!\nWorld")
3 /t 탭 출력 print("Hello!\tWorld")

2. tonumber(), tostring()

데이터 타입 변경

ex) tonumber("5") -> 5

tostring(5) -> "5"

tonumber("a5") -> nil 반환

 

3. bool : true, false

4. 논리 연산자 : and, or

ex ) print(false or false)

4. 변수

local 변수이름 = 입력할 데이터

local firstName = "Emma"

local randomNumbers = 125

local isThePlayerAFK = false

 

5. +=, -=, *=, /=

number += incrementValue -> number = number + incrementValue

 

6. 조건문(if then ... end)

local playerPosition = 1

연산자 예시
== 같음 5==5 -> true, 5==6 -> false
>=, > 크거나 같음, 큼  
<=, < 작거나 같음, 작음  
~= 다름  

if playerPosition == 1 then

    print("You are in the first place!")

end

6-1. 중첩 조건문

if playerPositon >= MINIMUM_PLAYERS and Player

 

7. 범위 (do ... end)

8. 파트(part) 속성 변경

  데이터 타입    
체크, 체크해제 bool Anchored true, false
숫자 숫자값 Transparency 0, 1, 0.2...
색상 Color3 (R,G,B)   Color3.framRGB(0,0,0) -- 검은색
Color3.framRGB(255,0,0) -- 흰색
위치, 크기,회전 Vector3 (X,Y,Z)   Vector3.new(25, 25, 25)

9. workspace

workspace 가져오기

local workspaceService = game:GetService("Workspace")

local workspaceService = workspace

local baseplate = workspace.Baseplate

baseplate.Reflectance = 1 -- 반사율 조정

10. 함수만들기(function)

function printSomething()

    print("This was prined in a function!")

end

printSomething()

 

func add(x,y)

print(x..y)

end

add(x, y)

11.typeof

if x == nil or typeof(x) ~= "number" then

    x = 0

end

12. table

table[1] n번째값 선택 tableName[1]
unpack   unpack(tableName)
insert 테이블 제일 뒤에 값 추가 table.insert(tableName, "addWord")
# 인덱스(길이)정보 얻기 #tableName
remove n 번째 인덱스에 있는 값 삭제 table.remove(tableName, 3)

13. 딕셔너리

15. 반복문

  while ... do ... end repeat .. until
사이클 실행 여부 실행 후 조건 확인 조건 확인 후 실행(최초1회는 무조건 실행)
실행 및 중지 조건 조건이 true 일 때 코드 실행 조건이 true일 때 코드 중지
사용예시 while cnt == 5 do
    cnt += 1
end
repeat
   cnt += 1
until
cnt == 5

for, continue, break

for i = 1, 10 do

print(i)

end

for numbrerCounter = 1, 10, 2 do

print(numberrCounter)

end

for i, v in pairs(messages) do

print(i, v)

end

 

 

서로다른 타입의 데이터를 저장할 수 있음

local students = {"William", "Sophie"}

local studentsInfo = {"William", 1028200, "Sophie", true}

math math.random(1,8) 입력한 두 사이 임의의 숫자를 반환
warn warn("warning!!")  
task.wait() task.wait(1) 1초동안 해당 스레드 중지
     
     
서비스    
Players game.GetServices("Players") local Players = game:GetServices("Players")
     
인스턴스    
player FindFirstChild
특정 이름을 가진 자식을 찾음
local Players = game:GetService("Players")
local player = Players:FindFirstChild(username)
  FindFirstChildOfClass
특정 클래스 명을 가진 자식을 찾음
local player = Players:FindFirstChildOfClass("Player")
  GetPlayers()
게임을 플레이하는 모든 플레이어 정보를 테이블로 받음
local players = Players:GetPlayers()

'로블록스' 카테고리의 다른 글

Script, Local Script  (0) 2025.02.28
기타 팁  (0) 2025.02.27
4. Event  (0) 2025.02.27
3. Module Script  (0) 2025.02.27
2. 약속  (0) 2025.02.27

+ Recent posts