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!
You are calling the function correctly. It's possible the problem lies within the code for youpunk, also you don't need to add else to every if statement unless you intend to do something if what you are checking is false. If it's making it to print(score) and score is still 0 then it would seem to me the youpunk() function ran without a problem however all of the if states did not do what you intended. To check this you can add prints for the elses in your if statements to see if what you are checking is true or not, and thus if it's adding to the score like you want it to.
Example:
if workspace.PartScoreBoard.SurfaceGui.Frame.Pin9.BackgroundColor3 == Color3.new(1, 0, 1) then score = score + 10 wait(0.2) else print("Hey we didn't add to the score because our check was false") end
Try putting return after all the elses, example:
if then --something else return end
And are you sure the function "youpunk" is created before everything else?
I am not even sure if "Pin1, Pin2, Pin3, Pin4, Pin5, Pin6, Pin7, Pin8 and Pin9" is a thing in a frame?