✓ Accepted answer
Please mark this as solved.
I had a quick look at the Jeeps roblox has for one of it's studio templates that uses the headsupdisplay
I originally thought that there was a maybe a read only variable already part of it but apparently not.
You can though use something like this:
local Speed = script.Parent.DriveSeat.Velocity.Magnitude
The downside is that it returns a float (a decimal)
So you'll end up with extremely long numbers like 79.9746372845.
I recommend you use some rounding to fix that though.
Edit:
I did just double check this and made a little line of code for printing it.
Since you can't print a float or an integer remember to convert to string first with tostring()
print(tostring(Speed))
Edit2:
If it is returning 0 here is what I suggest:
Create a new script inside the drive seat with the following code:
while true do
wait(1)
print(tostring(script.Parent.Velocity.Magnitude))
end
And make sure your driving the vehicle! Else your number will stay at 0 because your not moving!
8 comments
When I try to print it, all I get is 0
If your trying to print it convert it to a string first.
Are you printing it before the vehicle starts moving?
Its still at 0. I added a wait(5) before printing, so i would have time to drive before It prints. I also have no idea how to convert it to a string.
See edit2
Thanks, it worked! Now how can I use this number in a variable? Can I do local speed = script.Parent.Velocity.Magnitude ?
Yes that's exactly how you would use it.
Ok, thank you so much!