공부하는 Nar
article thumbnail
Published 2021. 12. 23. 10:28
[디토랜드] GetAllPlayer LuaScript

 

ServerScript

 

print("wait 15 second")
wait(15) --15초를 기다린뒤,

--게임의 모든 플레이어를 Game:GetAllPlayer()로 얻은 다음, 
--AllPlayer 변수에 할당해요.
local AllPlayer = Game:GetAllPlayer()

--반복문을 이용해서 AllPlayer 변수에 할당된 플레이어들의 이름을 print로 출력해요.
--첫번째(i = 1)부터 시작해서,
--AllPlayer의 크기(#AllPlayer)만큼 반복하고
--n번째 자식 오브젝트(AllPlayer[i])의 이름을 로그창에 출력해요.
for i = 1, #AllPlayer do
    print("Player Name : " .. AllPlayer[i]:GetName())
end

더보기

함수

string GetName()

객체의 이름을 얻을 수 있어요. 

 

샘플

print(Workspace.Floor:GetName()) --오브젝트의 이름을 문자열로 반환해요.

 



    -- Tip --
    멀티테스트로 실행하면 플레이어의 이름이 플레이어 수 만큼 출력되는 것을 확인할 수 있어요.

 

 

Script Log

 

profile

공부하는 Nar

@NarS2

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!