local UserBody = script.Parent
local User = game.Players:GetPlayerFromCharacter(UserBody)
local UserHumanoid = UserBody:WaitForChild("Humanoid")
local Sitting = false
UserHumanoid.Seated:Connect(function(IsSeated, Seat)
if IsSeated then
if Seat then
Sitting = true
local debounce = false
while task.wait(1) do
if debounce then return end
debounce = true
local UserHumanoidRootPart = UserBody:FindFirstChild("HumanoidRootPart")
if Sitting == true and UserHumanoidRootPart then
local Speed = UserHumanoidRootPart.AssemblyLinearVelocity.Magnitude
User.leaderstats.Money.Value = User.leaderstats.Money.Value + math.floor(Speed/37.5)
end
debounce = false
wait(1.5)
end
end
else
Sitting = false
end
end)
i want the script give money based on speed ONLY ONE TIME EACH SECOND. it works well to me , but whenever player join , it doesnt . Any reason ? Let me know
its not local script , and parent is StarterCharScript
Hadn’t noticed where you have the script. Scripts in StarterCharScripts wont be replicated to the server. Moving all of your logic to a server script will make this work. I got it to work by moving it all to a characterAdded function in a server script. Each player gets in a car and drives, and the money is given. Effectively, each player would have seen their own money go up, but the server wouldn’t and the other players wouldn’t. This way, they do.
i tried and got warn “inf yield possible on” . dont know to fix it , instead i use intvalue and it works well . “i put int value inside script” Thanks for helping me