I am new to scripting and i am trying to build a train and use a tactic for velocity to make it move. I made this code:

local clickDetector = workspace.Red.ClickDetector
     
    function onMouseClick()
    	game.Workspace.track_boy.Velocity = Vector3.new(-25,0,0)
		game.Workspace.track_man.Velocity = Vector3.new(-25,0,0)
    end
     
    game.clickDetector.MouseClick:connect(onMouseClick)

But it doesn't work.. Can someone tell me what's the problem or should i try something else?

3 comments

0

Your connection line says game.clickDetector.. I'm sure you want to access the Red within workspace for that. Also, what is track_boy and track_man, what type of objects are they

0

If they're just BaseParts, you'll want to use a BodyMover

0

Aha, i see