So, I've made a Goal-Line technology script w/ part, and in the script it has a message, it then destroys the message, but cause the ball bounces in then out of the net, it makes two messages and only one gets deleted. Here is the script:
script.Parent.Touched:connect(function(otherPart) if otherPart.Name == "TPS" or otherPart.Name == "Ball" then m = Instance.new("Message") m.Parent = Workspace m.Text = "Goal!" wait(4) m:Destroy() end end)
How do I make them both get deleted?
You would then add a debounce.
on = false script.Parent.Touched:connect(function(otherPart) if otherPart.Name == "TPS" or otherPart.Name == "Ball" then if on == false then on = true m = Instance.new("Message") m.Parent = Workspace m.Text = "Goal!" wait(4) m:Destroy() end end end)
There is a simple way to fix this: 1. Add a new script as a child of that script; 2. Make that script 'child' Disabled; 3. Make that script 'child' Name 'MessageScript'
The script 'child's code must be:
m = Instance.new("Message") m.Parent = Workspace m.Text = "Goal!" wait(4) m:Destroy() script:remove()
And then the normal script:
script.Parent.Touched:connect(function(otherPart) if otherPart.Name == "TPS" or otherPart.Name == "Ball" then cloneat = script.MessageScript:clone() cloneat.Parent = game.Workspace cloneat.Disabled = false end end)
Hope this helps! If it doesn't, tell me what appears in output. Thanks, marcoantoniosantos3