Every time i attempt debouce it doesn't work, what is it i'm doing wrong?
function onTouched(hit) local debounce = true if debounce == true then debounce = false game.ServerStorage.GameFiles.Storage.Area1:Clone().Parent = game.Workspace.GameFiles.MapStorage local part = game.Workspace.GameFiles.MapStorage.Area1.Location.Position wait(2) hit.Parent:moveTo(part) game.Workspace.GameFiles.MapStorage.SpawnMap:Destroy() end wait(10) debounce = true end connection = script.Parent.Touched:connect(onTouched)
You need to put 'local Debounce = true' above the function, not in it.
local debounce=true function onTouched(hit) if debounce == true then debounce = false game.ServerStorage.GameFiles.Storage.Area1:Clone().Parent = game.Workspace.GameFiles.MapStorage local part = game.Workspace.GameFiles.MapStorage.Area1.Location.Position wait(2) hit.Parent:moveTo(part) game.Workspace.GameFiles.MapStorage.SpawnMap:Destroy() end wait(10) debounce = true end connection = script.Parent.Touched:connect(onTouched)