part = script.Parent lastPos = part.Position store = 0 while true do local distance = part.Position - lastPos lastPos = part.Position store = store + distance.Magnitude wait() end
This script does not reflect at all how far the part has moved, based off on another script how fast it is going (the script is on a car)
Not sure why, but any help would be appreciated! (I am aware it is in studs)
Use Magnitude
with the subtraction (assuming store
is the total distance in studs)
local total = 0 local lastPos = part.Position while true do local distance = (part.Position - lastPos).Magnitude total = total + distance lastPos = part.Position wait() end