Untitled
unknown
plain_text
2 years ago
1.3 kB
5
Indexable
local userInputService = game:GetService("UserInputService")
local remoteEvent = game.ReplicatedStorage.WardrobeModelEntranceEvent
local remoteEventt = game.ReplicatedStorage.WardrobeMovingPart
local waiting = false
local playerInside = false
local function checkInput(input)
if input.KeyCode == Enum.KeyCode.Space then
remoteEvent:FireServer("EnterModel")
if playerInside == true then
remoteEvent:FireServer("ExitModel")
end
end
end
userInputService.InputBegan:Connect(checkInput)
remoteEvent.OnClientEvent:Connect(function(action, data)
if action == "Occupied" then
print("The model is already occupied by", data.Name)
elseif action == "PlayerInside" then
local previousPlayerInside = playerInside
playerInside = data
if playerInside and not previousPlayerInside then
print("Player entered the model!")
end
-- Handle the change in playerInside value as needed
print("Player inside model:", playerInside)
end
end)
local function checkInputt(input)
if input.KeyCode == Enum.KeyCode.Left and waiting == false and playerInside == true then
remoteEventt:FireServer("Movement")
print("Pressed")
waiting = true
wait(5)
waiting = false
end
end
userInputService.InputBegan:Connect(checkInputt)
Editor is loading...