i dont have an example sorry. im trying to make a currency type where you get certain amount of money every 1 mile you travel by car or walking but i dont understand so to start i would really appreciate it if someone could help me out with this.someone said i could use VVVVV but i dont know how to use that so it counts the amount of studs you traveled and give you a certain amount of money when you reach 1 mile. you do not have to make the script for me you can just maybe link me to stuff on wiki that might help me with this. TY
local dis = (oldPos-newPos).magnitude
.magnitude uses the good old Pythagorean Theorem to figure out the distance between a two points, your best bet is to use:
local dis = (oldPos-newPos).magnitude
Now what you can do is set the initial distance aka "oldPos" to the current location of the car, wait 0.5 and set newPos to the current location after 0.5 seconds. This gives the distance between two points after 0.5 seconds. You should run this in a loop, and have a seperate variable that holds the overall distance the vehicle has traveled. I suggest sending the distance to the player through a remote event, so a localscript can handle the distance, and put it in an integer, or if you want to be extra cautious, make the client ask for intvalue instead, so no hackers can change it.
Hope this helps.