Every single OnTouched function that I have done always spam, for example, I made a breakable glass the other day, where if you touch it the glass breaks, and it had the breaking part in replicated storage. Once I finished the script, I tested it, and it kept on grabbing the breakable part from replicated storage, and pasting it over and over again.. Any help would be appreciated...
You need to add a debounce to the script, a debounce is just a variable that you set to false before your function so you can check if it’s true before it can run. Say if debounce == false then debounce = true and then do whatever you want to do. To allow the player to break the glass again, just put a wait and then set debounce to false.
debounce = false function GlassBreak(hit) if not debounce and game.Players:GetPlayerFromCharacter(hit.Parent) then debounce = true --script-- end end
something like that, hope it helps. I'll update it if it is wrong :)