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

How to prevent it from spamming?

Asked by 5 years ago
script.Parent.Touched:Connect(function()
    print("Touched")
end)

1 answer

Log in to vote
1
Answered by
JakyeRU 637 Moderation Voter
5 years ago

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)
0
Thanks brother. Administrator_0007 26 — 5y
0
Why not simply do ``if CanPrint then`` instead of adding an "== true" into it? piRadians 297 — 5y
Ad

Answer this question