I am making a driving game, and I am new to coding, I am trying to implement a drive for money system, but can't find any tutorials to give me the resources to make the script, I already have a reward system in place, and all I need is a way of verifying if someone is driving, to give them money,I need a way of using variables across scripts, so I can verify that the car is moving
amount = 5
timedelay = 5
currencyname = "Cash"
if speed >0 then
wait(timedelay)
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("leaderstats") and v then
v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
end
end
end
the if speed > 0 then is the problem, since I am not able to share the 'speed' variable between scripts, the reward system does not function!
I put the script that measures the speed into the seat of the vehicle,
local seat = script.Parent
local speed = seat.Velocity.magnitude
print(speed)
I used the print to test out the script, so I could find the issue, but I haven't found out what to do. All help accepted and improvements for the script in general accepted too! phoniexgaming(I call myself PhonieZGaminZ now!)

3 comments
thanks
but how do I get the speed of the players vehicle from the leaderstats script?
car.VehicleSeat.Velocity.Magnitude