How would I give them money for driving?

So I want to give the player driving the car for every 5-10 minutes they drive they get money but they do not get it if they do not drive kind of like vehicle simulator. How would I do this?

simply, check for Seat.Occupant

Every 5/10 minutes give them money if they’re detected in the occupant.

1 Like

Is there a function that checks how many studs the vehicle travels?

1 Like

Magnitude but it would be useless really

1 Like

Well if you can figure out how much the driver travelled you can make an equation to give money after 5-10 minutes no?

1 Like

I guess we can give the amount of money of magnitude but you can use seat.occupant to see if player is riding it

1 Like

So the way I would do it is Player.Money.Value += (Car.Velocity.magnitude / Car.MaxStudsPerSecond) * (math.random() * MaxMoneyTheyShouldMakePerSecondOrMinute)
Car.MaxStudsPerSecond should be the max velocity it can go.

It isn’t the most perfect method but it works
P.S. math.random() returns a random value between 0-1 meaning that it could return 0.0001

Feel free to reply if you need me to explain anything


Is there anything I have to edit in this script or can I just put it in?

There’s a lot you have to edit, I made it like that so you can learn instead of just copy and pasting

The Car in Car.Velocity.magnitude can be any object inside the car assuming its any type of part and it moves with the car.
I hope you can figure out Car.MaxStudsPerSecond on your own


This is a good way but the way i do it is like this feel free to use this code if you want:

local players = game:GetService("Players")
local distancePerMile = 10000 -- This is the distance they need to travel in studs to earn 1 mile on their leaderstats

	local character = plr.Character or plr.CharacterAdded:Wait()
	local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")

	local count = 0
	local oldPointCash = humanoidRootPart.Position
	local newPointCash = humanoidRootPart.Position
	local oldPoint = humanoidRootPart.Position
	local newPoint = humanoidRootPart.Position

	while wait(1) do
		if character:FindFirstChild("Humanoid").Sit == true then
			newPoint = humanoidRootPart.Position

			if (oldPoint - newPoint).Magnitude >= distancePerMile then
				-- This will add miles to the datastore so like player.leaderstats.Miles += 1	
				oldPoint = humanoidRootPart.Position

				oldPointCash = newPointCash
				newPointCash = humanoidRootPart.Position
			local cashAwarded = ((oldPointCash - newPointCash).Magnitude) /5
				if cashAwarded < 200 then
					-- this will add the cash: -- += math.floor(cashAwarded	* 3.5)		
1 Like

There are many ways to calculate the time driven as well as many ways to calculate the amount of money to give.

One way could be starting a 5 minute timer when they get in the car, and either stopping it when they get out or waiting until it ends to check if they’re still in the car.
Another could just be having a global timer to see if the user is in a car every 5 minutes.

(Personally these sound annoyingly slow and also easily abused, I’d suggest giving money based on distance travelled + multiplying it by a little bit on slower cars so they don’t take forever to earn anything)