Working on an active train with Velocity's, but I want the train to stop when a player touches the track. I don't want the player to go with the train, when he touches the tracks. Can someone help me fix this script, and tell me what I did wrong?
TA = script.Parent.Parent.Train.A -- Locamotive
TB = script.Parent.Parent.Train.B -- Locamotive
B = script.Parent.Parent.Part -- Track
player = game.Players
B.Velocity = Vector3.new(-30,0,0) --Train speed
function onTouch()
if player (onTouch)then
B.CanCollide = false
TA.Anchored = true
TB.Anchored = true
else
B.CanCollide = (true)
TA.Anchored = false
TB.Anchored = false
end
end
B.Touched:connect(onTouch)

2 comments
One issue, my mistake, but I would like the train to continue if the player comes back off it
http://wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded