Hi i want an explosion to happen only once heres my script
function onTouched(hit) wait(5) explosion = Instance.new("Explosion") explosion.BlastRadius = 20 explosion.BlastPressure = 20000 explosion.Position = hit.Position explosion.Parent = game.Workspace wait(15) end script.Parent.Touched:connect(onTouched)
except when something hits the part explosions keep happening, how can i make the explosion happen once ???
Add debounce. It would look like this
local debounce = false function onTouched(hit) if debounce == true then return end debounce = true wait(5) explosion = Instance.new("Explosion") explosion.BlastRadius = 20 explosion.BlastPressure = 20000 explosion.Position = hit.Position explosion.Parent = game.Workspace wait(15) --debounce = false --Uncomment that if you want it to happen again end script.Parent.Touched:connect(onTouched)
There is also a wiki article - http://wiki.roblox.com/index.php?title=Debounce