Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to make a one way script?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.