So I have a script that opens a gui ontouch, however, if you touch it again after 2 seconds, it opens up another gui and layers up. I need a way to resolve this. Thanks =^)
debounce = true script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum ~= nil and debounce == true then debounce = false local player = game.Players:FindFirstChild(hum.Parent.Name) local Gui = script.Parent.FrameWork:clone() Gui.Parent = player.PlayerGui wait(1) debounce = true end end)
Hey Skepticlemon,
local debounce = true script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum ~= nil and debounce == true then local player = game.Players:FindFirstChild(hum.Parent.Name) if not player.PlayerGui:FindFirstChild("FrameWork") then -- Checks if the object 'FrameWork' is really inside of the PlayerGui. If it's not then it will pass the if statement. debounce = false local Gui = script.Parent.FrameWork:clone() Gui.Parent = player.PlayerGui wait(1) debounce = true end end end)
~~ KingLoneCat