score = 0
workspace.PartSensor.Touched:connect(function(Otherpart)
if Otherpart.Name == 'Bowling Ball' then
youpunk() -- The function i'm trying to call, which will begin the scan.
wait(2)
print(score)
end
end)
For some strange reason, I cannot get youpunk() to be called, and it ends up printing the score as 0, even though it should be scanning, It might be this code that messed up but
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin1.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
I don't think anything is wrong there, I repeat the script above nine times with 9 different "Pin1-Pin9" Background colors..
score = 0
workspace.PartSensor.Touched:connect(function(Otherpart)
if Otherpart.Name == 'Bowling Ball' then
youpunk()
wait(2)
print(score)
end
end)
function youpunk()
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin1.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin2.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin3.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin4.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin5.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin6.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin7.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin8.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin9.BackgroundColor3 == Color3.new(1, 0, 1) then
score = score + 10
wait(0.2)
else
end
end
Assistance would be great!

1 comment
You'd be much better off with .changed events. And you could put all the pins in a loop and have your whole script in probably less than 25 lines.