If the VehicleSeat HeadsUpDisplay property is set to true, it shows a gui displaying the speed of the vehicle. How can I calculate that value, if it's a single number and the Velocity property of the seat is a Vector3?
How to calculate the speed of a vehicle (seat)?
3 answers
Ive tested this in studio. It might not be what you want. But this is what I found out and it works when I tested a car
local speed = 0
while (true) do
local p1 = script.Parent.Position
local t = wait()
local p2 = script.Parent.Position
local d = (p1-p2).magnitude
speed = math.floor(d/t)
print(speed) -- Showing the speed on the output
end
Velocity is a Vector3 value, and every Vector value has a magnitude. The magnitude of a vector is basically how long the vector is, or the distance between itself and (0,0,0). In order to get the magnitude of a Vector, you simply type the name of the Vector and put .magnitude at the end of it to get the magnitude, like so:
local Speed = script.Parent.Velocity.magnitude
Hope this helped!
2 comments
does it work?
Yes, this is what the VehicleSeat uses to display speed.
this script goes inside the seat.
local sp = script.Parent
while wait() do local speed = math.floor(sp.Velocity.magnitude + .5)
print(speed)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
very intelligent, thx