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

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

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.)

2 comments

0

Remove line 6

0

done

1 answer

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!

1 comment

0

gonna accept your answer since the other guy in comments solved it.

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