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
4 years ago
Edited 4 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.

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

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 — 4y
0
done notfenv 171 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Use a wait and a debounce.

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

Hope this helps!

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

Answer this question