I have a script that teleports you and clones a GUI into the player when the player touches a part. However, theres always multiple GUI's being cloned. I've tried to stop this with a debounce, but it wouldn't work. I'm not sure if I'm doing something wrong.
local seats = game.Workspace.room1.seats:GetChildren()
local exitgui = script.Parent.exitgui
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if debounce == false then
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
for i,v in pairs(seats) do
if seats.Occupant == nil then
hit.Parent.Humanoid.JumpPower = 0
hit.Parent.Humanoid.WalkSpeed = 0
script.Parent.slam:Play()
exitgui:Clone().Parent = player.PlayerGui
player.Character.HumanoidRootPart.CFrame = seats[math.random(1,10)].CFrame
end
end
end
end
end)

1 comment
You need to change debounce back to false before you end.