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

This script spams my print command but I don't know how to stop it?

Asked by 5 years ago

I've made a script for a part, and when you click the part, it does this: Hit.Name.. but this spams it until I get off the part, how do I make it stop

local Part = game.Workspace.Part
Part.Touched:Connect(function(Hit)
    print(Hit.Name.." touched")
end)

1 answer

Log in to vote
0
Answered by 5 years ago

You will need a debounce/cooldown, this works by setting the cooldown to false (it's a boolean) , when the touched event triggers, add an if statement checking if the cooldown is false, and if it is false, set the cooldown to true and then run the code needed, then you can make it wait a specific amount of time and set it back to false

Ad

Answer this question