Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Where would i put if not debounce?

wait(3)
script.Parent.Visible = true

local frame = script.Parent.Parent.Parent:WaitForChild('First')
local debounce = false
local on = false

local char = game.Players.LocalPlayer.Character.Humanoid

local cam = workspace.Camera
local int = require(game.ReplicatedStorage.Interpolate)

script.Parent.MouseButton1Click:connect(function()
if on then
 game.ReplicatedStorage.Sounds.Click:Play()
		frame:TweenPosition(UDim2.new(0, -500,0.5, -173),"In","Quad",.5,true)     --Close
		cam.CameraType = "Custom"
		wait(.4)
	 on = false
else
	cam.CameraType = "Scriptable"
		int.Interpolate(cam,CFrame.new(6.75,78.302,0.25), CFrame.new(0,78,0), "InOut", "Quart", 1)  --Open
		game.ReplicatedStorage.Sounds.Click:Play()
		frame:TweenPosition(UDim2.new(0, 0,0.5, -173),"Out","Quad",.5,true)
		wait(.4)
		on = true
	end
end)

1 answer

✓ Accepted answer

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!

wait(3)
script.Parent.Visible = true

local frame = script.Parent.Parent.Parent:WaitForChild('First')
local debounce = false
local on = false

local char = game.Players.LocalPlayer.Character.Humanoid

local cam = workspace.Camera
local int = require(game.ReplicatedStorage.Interpolate)

script.Parent.MouseButton1Click:connect(function()
if not debounce then --Debounce is off
	debounce = true --Turns debounce on
if on then
 game.ReplicatedStorage.Sounds.Click:Play()
        frame:TweenPosition(UDim2.new(0, -500,0.5, -173),"In","Quad",.5,true)     --Close
        cam.CameraType = "Custom"
        wait(.4)
     on = false
else
    cam.CameraType = "Scriptable"
        int.Interpolate(cam,CFrame.new(6.75,78.302,0.25), CFrame.new(0,78,0), "InOut", "Quart", 1)  --Open
        game.ReplicatedStorage.Sounds.Click:Play()
        frame:TweenPosition(UDim2.new(0, 0,0.5, -173),"Out","Quad",.5,true)
        wait(.4)
        on = true
    end
end --The closer for the debounce checker
debounce = false --Turn debounce back off after done running code
end)

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.