Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 7 days ago
Edited 7 days 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 incapaxx 3252 — 7d
0
done kanchoplets 20 — 7d

1 answer

Log in to vote
0
Answered by 7 days 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. kanchoplets 20 — 6d
Ad

Answer this question