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

Ball OnTouched help?

Asked by 9 years ago

Basically, whenever I put this script that I made into the nets it does not do what it is supposed to do, can you guys help? Basically, I want it to shout a message saying goal and enable it to where all the boolvalues in the goals would be true when a goal has happened, but it isn't showing anything in the error output and I have almost everything to see what is going on. If you could help me, that would be great.

v What I am putting the script into. Link1 v is the ball going into the goal. Link2

hit1 = script.Parent.Parent.GoalNet1.Hit
hit2 = script.Parent.Parent.GoalNet2.Hit
hit3 = script.Parent.Parent.GoalNet3.Hit
hit4 = script.Parent.Parent.GoalNet4.Hit



function onTouched(hit) 
if hit.Name == "Ball" and hit1 == false and hit2 == false and hit3 == false and hit4 == false  then
hit1 = true
hit2 = true
hit3 = true
hit4 = true
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "GOOOOOAAAAAAAAAAAAALLLLLLLLLLL!"
wait(5)
m:remove()
hit1 = false
hit2 = false
hit3 = false
hit4 = false
end
end
script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 9 years ago

If the name of the values inside the Goalnets are "Hit", then try this:

hit1 = script.Parent.Parent.GoalNet1.Hit
hit2 = script.Parent.Parent.GoalNet2.Hit
hit3 = script.Parent.Parent.GoalNet3.Hit
hit4 = script.Parent.Parent.GoalNet4.Hit



function onTouched(hit) 
if hit.Name == "Ball" and hit1.Value == false and hit2.Value == false and hit3.Value == false and hit4.Value == false  then
hit1 = true
hit2 = true
hit3 = true
hit4 = true
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "GOOOOOAAAAAAAAAAAAALLLLLLLLLLL!"
wait(5)
m:remove()
hit1 = false
hit2 = false
hit3 = false
hit4 = false
end
end
script.Parent.Touched:connect(onTouched)

What I see is wrong is that you forgot to do ".Value" after hit1, hit2, etc. Hope this works!

Ad

Answer this question