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

How to prevent it from spamming?

script.Parent.Touched:Connect(function()
	print("Touched")
end)

1 answer

✓ Accepted answer

Hello. Use Debounce.

CanPrint = true

script.Parent.Touched:Connect(function()
	if CanPrint == true then
		CanPrint = false
		print("Touched")
		script.Parent.BrickColor = BrickColor.new("Really red")
		wait(3) --Cooldown
		CanPrint = true
		script.Parent.BrickColor = BrickColor.new("Lime green")
	end
end)

2 comments

0

Thanks brother.

0

Why not simply do if CanPrint then instead of adding an "== true" into it?

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