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:

01script.Parent.Touched:connect(function(otherPart)
02  if otherPart.Name == "TPS" or otherPart.Name == "Ball" then
03        if script.Parent.Size.y <5 and script.Parent.Size.x <5 and script.Parent.Size.z <5 then
04            script.Parent.Boing.Pitch = 1
05        end
06        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
07            script.Parent.Boing.Pitch = 0.8
08        end
09        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
10            script.Parent.Boing.Pitch = 0.6
11        end
12        if script.Parent.Size.y >12 and script.Parent.Size.x >12 and script.Parent.Size.z >12 then
13            script.Parent.Boing.Pitch = 0.4
14        end
15        script.Parent.Goal:Play()
16end
17end)

Script 2:

1script.Parent.Touched:connect(function(otherPart)
2    if otherPart.Name == "TPS" or otherPart.Name == "Ball" then
3        m = Instance.new("Message")
4        m.Parent = Workspace
5        m.Text = "Goal!"
6        wait(4)
7        m:Destroy()
8    end
9end)

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.

01enabled = true
02script.Parent.Touched:connect(function(otherPart)
03if not enabled then
04return
05end
06 if otherPart.Name == "TPS" or otherPart.Name == "Ball" then
07enabled = false
08        m = Instance.new("Message")
09        m.Parent = Workspace
10        m.Text = "Goal!"
11        wait(4)
12        m:Destroy()
13enabled = true
14    end
15end)

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