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

Problem with this script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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?

2 answers

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)

Ad
Log in to vote
0
Answered by 9 years ago

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

Answer this question