Every time i attempt debouce it doesn't work, what is it i'm doing wrong?
01 | function onTouched(hit) |
02 | local debounce = true |
03 | if debounce = = true then |
04 | debounce = false |
05 | game.ServerStorage.GameFiles.Storage.Area 1 :Clone().Parent = game.Workspace.GameFiles.MapStorage |
06 | local part = game.Workspace.GameFiles.MapStorage.Area 1. Location.Position |
07 | wait( 2 ) |
08 | hit.Parent:moveTo(part) |
09 | game.Workspace.GameFiles.MapStorage.SpawnMap:Destroy() |
10 | end |
11 | wait( 10 ) |
12 | debounce = true |
13 | end |
14 |
15 | connection = script.Parent.Touched:connect(onTouched) |
You need to put 'local Debounce = true' above the function, not in it.
01 | local debounce = true |
02 |
03 | function onTouched(hit) |
04 | if debounce = = true then |
05 | debounce = false |
06 | game.ServerStorage.GameFiles.Storage.Area 1 :Clone().Parent = game.Workspace.GameFiles.MapStorage |
07 | local part = game.Workspace.GameFiles.MapStorage.Area 1. Location.Position |
08 | wait( 2 ) |
09 | hit.Parent:moveTo(part) |
10 | game.Workspace.GameFiles.MapStorage.SpawnMap:Destroy() |
11 | end |
12 | wait( 10 ) |
13 | debounce = true |
14 | end |
15 | connection = script.Parent.Touched:connect(onTouched) |