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

How do I make a curtain open and close with one button with debounce?

Asked by
notfenv 171
5 years ago
Edited 5 years ago

Yet again, still making my border game, but this time its like a scanning feature.

You press the scan button The curtain closes You wait 4 seconds. The curtain opens.

Heres my script, I attempted it myself, but it broke the whole script, so it doesnt make me say anything or doesnt play the sound.

01local LastNext = tick()
02script.Parent.ClickDetector.MouseClick:connect(function(Player)
03    if (not Player.Team or Player.Team.Name == 'Admission') and tick()-LastNext > 3 then
04        workspace:WaitForChild('BoothSFX').Talk:Play()
05        game:GetService("Chat"):Chat(Player.Character,'Please face the scanner.', 'White')
06         -- Below is where I am having issues.
07        script.Parent.Parent.curtain.CanCollide = true
08        script.Parent.Parent.curtain.Transparency = 0
09        wait(4)
10        script.Parent.Parent.curtain.CanCollide = false
11        script.Parent.Parent.curtain.Transparency = 1
12    end
13end)

Can anyone help? (note that the button is called "Scan" in workspace, and curtain is called "curtain", they are GROUPED.)

0
Remove line 6 User#24403 69 — 5y
0
done notfenv 171 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Use a wait and a debounce.

1local debounce = true
2--game.Workspace.(Whatever items here).ClickDetector.MouseClick:Connect(function()
3if debounce then
4        debounce = false
5        wait(add any amount you want)
6        debounce = true
7end

Hope this helps!

0
gonna accept your answer since the other guy in comments solved it. notfenv 171 — 5y
Ad

Answer this question