1. UI 추가 방법
- StarterGUI -> ScreenGUI 안에 UI를 추가 할 수 있다.
- 해당 UI는 화면에 항상 고정되어 나타난다.
- 혹은 메뉴 -> home -> UI 에서 추가 가능하다.
2. UI 상호작용
- 버튼 상호작용 예 (Local Script)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local playerGui = game.Players.LocalPlayer.PlayerGui
local screenGui = playerGui:FindFirstChild("ScreenGui")
local uis = screenGui:GetChildren()
for _,item in pairs(uis) do
if item.Name == 'UI이름' and item.ClassName == 'UI타입' then
item.Activated:Connect(function()
--아래 코드는 서버 스크립트로 이벤트를 보내는 코드
local remoteEvent = game.ReplicatedStorage.RemoteEvent
remoteEvent:FireServer(item.Name)
end)
end
end
3. 서버 스크립트 이벤트 수신
local remoteEvent = Instance.new("RemoteEvent")
remoteEvent.Name = "RemoteEvent"
remoteEvent.Parent = game.ReplicatedStorage
-- 클라이언트로부터 이벤트 수신
remoteEvent.OnServerEvent:Connect(function(player,name)
print(name)
-- 캐릭터와 버튼 이름 수신. 필요할시 인자값을 더 늘리면 된다.
end)
'로블록스 게임제작' 카테고리의 다른 글
코루틴 (0) | 2024.02.14 |
---|---|
RESTAPI 통신 및 모듈스크립트 호출 (0) | 2024.02.13 |
캐릭터에 악세서리 추가 (0) | 2024.02.13 |
캐릭터 이동확인 이벤트 (0) | 2024.02.13 |
로컬 스크립트 - 이용자 버튼 입력 이벤트 감지 (0) | 2024.02.13 |