Vehicle script works in studio but not in the real game?

So the code works fine in studio, you can turn and move forward and backwards but in the real game you dont move or turn at all.



This isn’t the answer to your problem but…

while wait(0.00000000001) do

Don’t do this. This is the same as while wait() do. Use Stepped instead. Same with wait(0.001) and wait(0.0001).

As for the answer, what type of Script is this and where is it placed?

Normal vehicle script that i made and it is located in the vehicle. Play the game if you need more info.

Is this the only script related to moving the vehicle? I don’t see anything related to moving it, is it not player controlled?

EDIT: Just noticed VehicleSeat.Steer, nevermind.

the align position moves it, its the only script and it is player controlled.

is it the align position because if it is I have no idea why…

You have a very interested method of moving the vehicle. First time I’ve seen something like this. I will say it’s extremely inefficient.

The best and easiest method I’ve seen is to do this:

  • Create BodyPosition, BodyVelocity, and BodyGyro
  • Set BodyPosition.MaxForce =,1e5,0)
  • Set BodyGyro.MaxTorque =,1e5,1e5)
  • Set BodyVelocity.MaxForce =,0,1e5)
  • During loop, do: BodyPosition.Position =,rayHitPosition.y+5,0)
    • +5 is how far away the ship will be from where the ray it the floor
  • During loop, do: BodyVelocity.Velocity =,0,script.Parent.VehicleSeat.Throttle*Speed)
    • If it moves the wrong way, add a - to Speed
  • During loop, do: BodyGyro.CFrame = BodyGyro.CFrame*CFrame.Angles(0,script.Parent.VehicleSeat.Steer*SteeringSpeed,0)
    • Same as above, add a - if it turns the wrong way

You might have to play with MaxForce and MaxTorque and the 1e5. If you do it too high, it will disappear. Too low and it won’t turn/float. Also, you might have to play with the P and D properties of BodyPosition and BodyGyro (And just in-case you didn’t know, 1e5 means one with five zeros.) There’s probably a better and more methodical way of setting MaxForce and MaxTorque, maybe someone will explain.

Hopefully I explained everything well enough. If you don’t know how these BodyObjects work, I would open a new place, place a part in, then place each BodyObject separately and change the properties to see what they do (you need to have the game running with either play or run.)

1 Like

Hey. Also not an answer to your question, but you should do:, (End - Start))
not like you have done:, End)
Edit: Why, -500, 0).p instead of, -500, 0), while .p returns exactly the vector value (which is same as cframe, just it doesn’t contain rotation).

1 Like

stays still :c

game file: itsthecar.rbxl (62.7 KB)

when i add the velocity it does not work.

itsthecar.rbxl (64.7 KB)

This should work. I was bored and decided to greatly improve the script. Hope you learn a lot and not just stick it in your game without learning how I did it.

Good luck!