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

Is it possible to make a one way script?

Asked by 10 years ago

So basically, I have a goal-line technology system that is in BETA, I'm testing it out, it will make a sound and message saying "Goal!" when the ball goes over the line, then the message SHOULD get deleted, but when it gets deleted, another message get's created when the ball bounces back out from the back of goal, can you fix this?

Script 1:

script.Parent.Touched:connect(function(otherPart)
  if otherPart.Name == "TPS" or otherPart.Name == "Ball" then
        if script.Parent.Size.y <5 and script.Parent.Size.x <5 and script.Parent.Size.z <5 then
            script.Parent.Boing.Pitch = 1
        end
        if script.Parent.Size.y >4 and script.Parent.Size.y <9 and script.Parent.Size.x >4 and script.Parent.Size.x <9 and script.Parent.Size.z >4 and script.Parent.Size.z <9 then
            script.Parent.Boing.Pitch = 0.8
        end
        if script.Parent.Size.y >8 and script.Parent.Size.y <13 and script.Parent.Size.x >8 and script.Parent.Size.x <13 and script.Parent.Size.z >8 and script.Parent.Size.z <13 then
            script.Parent.Boing.Pitch = 0.6
        end
        if script.Parent.Size.y >12 and script.Parent.Size.x >12 and script.Parent.Size.z >12 then
            script.Parent.Boing.Pitch = 0.4
        end
        script.Parent.Goal:Play()
end
end)

Script 2:

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)

If you want too test the system, come too my place, my usernames is iJava7, it's called "Goal-Line Technology - BETA", I'm currently there and updating it if you want too try it out and fix it.

1 answer

Log in to vote
0
Answered by 10 years ago

Try creating debounce.

enabled = true
script.Parent.Touched:connect(function(otherPart)
if not enabled then
return
end
 if otherPart.Name == "TPS" or otherPart.Name == "Ball" then
enabled = false
        m = Instance.new("Message")
        m.Parent = Workspace
        m.Text = "Goal!"
        wait(4)
        m:Destroy()
enabled = true
    end
end)

This will make it so the script runs once and after 4 seconds it becomes enabled again.

http://wiki.roblox.com/index.php?title=Debounce

Ad

Answer this question