Why is this happening?

So my cash per mile system if bugging it says that the leader stats is not what the player has but the values are the same

pic 3
pic 2
pic 1

You named it leaderstats not lead. Change it.

Replace lead with leaderstats. leaderstats is what the folder is named

image

Can you show me your current script?

image

Can you put print(player) above line 14 then try the script and show me what it prints?

image

It cannot find “leaderstats” in player

You are encountering an error because of the loop, the while loop may run before the player variable is even set to something other than nil. Try this instead:

local MeteresDriven = script.MeteresDriven

local startLoop = coroutine.wrap(function (Player)
    while task.wait(1) do
        MeteresDriven.Value = MeteresDriven.Value + script.Parent.Velocity.Magnitude
        if MeteresDriven.Value > 200 then
            MeteresDriven.Value = 0
            Player.lead.Wallet.Value += 550
            Player.lead.Miles.Value += 1
        end
    end
end)

script.Parent.Touched:Connect(function ()
    if hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players[hit.Parent.Name]
        startLoop(Player)()
    end
end)

This loop runs when the player value is set to an actual player.
You can also use:

while Player ~= nil then
end

instead.

2 Likes

hit is being underlined is that a mistake?

Change it to player.leaderstats not player.lead

not the problem has been fixed

its something else wrong with it

Okay then mark the topic solved.

nope still a problem lol i need to check

So one of the problems is fixed but there is another problem in the script?

its done now thank for the help