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)

2 comments
Collision detection are not very good at high speeds. You could always try a Ray Cast.
I could help because I did something similar to this.If you would like?