Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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?

0
Use Debounce. I believe it's in the scripting glossary. GoldenPhysics 474 — 10y

1 answer

Log in to vote
0
Answered by
Destrings 406 Moderation Voter
10 years ago

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)
0
Wow, thanks man! TheeDeathCaster 2368 — 10y
Ad

Answer this question