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.
Code: https://pastebin.com/k4rVMVmp
Game: https://www.roblox.com/games/1323116059/Supreme-Leader-Smoke
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.
Code: https://pastebin.com/k4rVMVmp
Game: https://www.roblox.com/games/1323116059/Supreme-Leader-Smoke
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:
BodyPosition
, BodyVelocity
, and BodyGyro
BodyPosition.MaxForce = Vector3.new(0,1e5,0)
BodyGyro.MaxTorque = Vector3.new(1e5,1e5,1e5)
BodyVelocity.MaxForce = Vector3.new(1e5,0,1e5)
BodyPosition.Position = Vector3.new(0,rayHitPosition.y+5,0)
+5
is how far away the ship will be from where the ray it the floorBodyVelocity.Velocity = Vector3.new(0,0,script.Parent.VehicleSeat.Throttle*Speed)
-
to Speed
BodyGyro.CFrame = BodyGyro.CFrame*CFrame.Angles(0,script.Parent.VehicleSeat.Steer*SteeringSpeed,0)
-
if it turns the wrong wayYou 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.)
Hey. Also not an answer to your question, but you should do:
Ray.new(Start, (End - Start))
not like you have done:
Ray.new(Start, End)
Edit: Why CFrame.new(0, -500, 0).p
instead of Vector3.new(0, -500, 0)
, while .p returns exactly the vector value (which is same as cframe, just it doesn’t contain rotation).
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!
thanks!