This script is inside a brick that is one stud wide and a vehicle travelling at 60sps is going through that brick. This is meant to change the value in the vehicle yet it only does it some of the time, usually when going slower. (Rarely works on the first collision either)
I've tried making the brick longer but no luck. Can anyone see why?
Detector = script.Parent enabled = true BrickValue = 31 function onTouch(part) if not enabled then return end enabled = false local player = game.Players:GetPlayerFromCharacter(part.Parent) local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and player~= nil then local bus = Workspace:FindFirstChild(player.Name.."'s Car") if bus:FindFirstChild("Fifteen")then bus.CurrentScore.Value = bus.CurrentScore.Value + BrickValue wait(3) end end wait() enabled = true end Detector.Touched:connect(onTouch)
You checked the player before the time.
Detector = script.Parent enabled = true BrickValue = 31 function onTouch(part) if not enabled then return end enabled = false if part.Parent:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(part.Parent) then local bus = Workspace:FindFirstChild(player.Name.."'s Car") if bus:FindFirstChild("Fifteen")then bus.CurrentScore.Value = bus.CurrentScore.Value + BrickValue wait(3) end end wait() enabled = true end Detector.Touched:connect(onTouch)
But don't forget to look for an if statement that doesn't fit. Put some prints in each part and look the output.
just a few things to say, game.Players:GetPlayerFromCharacter() doesn't work... u need to give the system the Character not the Players to get the PlayerFromCharacter... also, u don't need
if (this ~= nil) and anotherthing ~= nil then
u don't need those Brackets :P