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

How can I do a script that doesn't do too many prints when onTouched?

I do not know how to make a script where you just step on a brick once and it wont spam allot of prints, for instance when I made a script (In Studio) where it prints the Player's name, but it printed over 4-7 times when I only want it to do it once, a little help please?

1 comment

0

Use Debounce. I believe it's in the scripting glossary.

1 answer

✓ Accepted answer

You are talking about Debounce

The concept is simple, you have a variable to track whether the brick has been recently touched.

tched = false --Variable

script.Parent.Touched:connect(function()
	if  tched == false then 
		print("Hi")
		tched = true
		wait(3)
		tched = false
	end
end)

1 comment

0

Wow, thanks man!

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