03 PlayerSetup 스크립트에 아래 코드를 입력합니다. 스크립트를 이용하여 점수를 담을 공간을 만듭니다.

     

    코드 | 파일명: PlayerSetup.lua

    --onPlayerJoin 함수 : 점수 담는 공간을 만드는 함수
    local function onPlayerJoin(player)            --함수 정의
        local leaderstats = Instance.new("Folder") --새로운 폴더 만들기
        leaderstats.Name = "leaderstats"           --폴더 이름 leaderstsats로 변경
        leaderstats.Parent = player                --폴더의 Parent를 player로 지정
        --표시할 점수 항목 만들기
        local points = Instance.new("IntValue")    --정수(Int) 타입의 값 만들기
        points.Name = "Points"                     --이름을 Points로 변경
        points.Value = 0                           --Points의 초깃값을 0으로 지정
        points.Parent = leaderstats                --Points의 Parent를 leaderstats 폴더로 지정
     
        local items= Instance.new("IntValue")   --정수(Int) 타입의 값 만들기
        items.Name = "Items"                    --이름을 Items로 변경
        items.Value = 0                         --Items의 초깃값을 0으로 지정
        items.Parent = leaderstats              --Items의 Parent를 leaderstats 폴더로 지정
     
        local spaces = Instance.new("IntValue")   --정수(Int) 타입의 값 만들기
        spaces.Name = "Spaces"                    --이름을 Spaces로 변경
        spaces.Value = 0                          --Spaces의 초깃값을 0으로 지정
        spaces.Parent = leaderstats   --Spaces의 Parent를 leaderstats 폴더로 지정
    end
    
    --Player가 게임에 들어오면 onPlayerJoin 함수 실행
    game.Players.PlayerAdded:Connect(onPlayerJoin) 
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.