New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
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 11 months ago
Edited 11 months 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 26 — 11mo
0
done kanchoplets 56 — 11mo

1 answer

Log in to vote
0
Answered by 11 months 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 56 — 11mo
Ad

Answer this question