Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Where would i put if not debounce?

Asked by 7 years ago
01wait(3)
02script.Parent.Visible = true
03 
04local frame = script.Parent.Parent.Parent:WaitForChild('First')
05local debounce = false
06local on = false
07 
08local char = game.Players.LocalPlayer.Character.Humanoid
09 
10local cam = workspace.Camera
11local int = require(game.ReplicatedStorage.Interpolate)
12 
13script.Parent.MouseButton1Click:connect(function()
14if on then
15 game.ReplicatedStorage.Sounds.Click:Play()
View all 28 lines...

1 answer

Log in to vote
0
Answered by 7 years ago

If you want it to be unclickable while in-between opening and closing, this is the best way to do it.

Before checking if it's "on" or vice versa, it will check if debounce is false. If true, then that means it's still running code and can't be used.

Here's how it should look. Hope this helps!

01wait(3)
02script.Parent.Visible = true
03 
04local frame = script.Parent.Parent.Parent:WaitForChild('First')
05local debounce = false
06local on = false
07 
08local char = game.Players.LocalPlayer.Character.Humanoid
09 
10local cam = workspace.Camera
11local int = require(game.ReplicatedStorage.Interpolate)
12 
13script.Parent.MouseButton1Click:connect(function()
14if not debounce then --Debounce is off
15    debounce = true --Turns debounce on
View all 32 lines...
0
Thanks! SamthekidRSsl 58 — 7y
Ad

Answer this question