Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Money reset script will not reset player money why?

Asked by
MHaven1 159
7 years ago
local player = game.Players.LocalPlayer
repeat wait()
until player:FindFirstChild("leaderstats").Money.Value >= 7000000
if player:FindFirstChild("leaderstats").Money.Value >= 7000000 then
    local m = Instance.new("Message")
    m.Text = "Stats Have Been Reset"
    m.Parent = player.PlayerGui
    wait(5)
    m:Destroy()
    player:FindFirstChild("leaderstats").Money.Value = 0
    script.Disabled = true
end

i want this script to reset money if players money is higher then 7 million but this script will now reset players money. please help. this is a local script in playergui. there is a leaderboard in the game which works fine. error: Players.MHaven1.PlayerGui.LocalScript:3 attempt to index a nil value.

0
I think you should do repeat wait() until player:FindFirstChild("leaderstats").Money.Value >= 7000000 on one line, but I'm not sure itsJooJoo 195 — 7y
0
ok MHaven1 159 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
local player = game.Players.LocalPlayer
    while wait() do
    if player:WaitForChild("leaderstats").Money.Value >= 7000000 then
        player:WaitForChild("leaderstats").Money.Value = 0
        local m = Instance.new("Message")
        m.Text = "Stats Have Been Reset"
        m.Parent = player.PlayerGui
        wait(5)
        m:Destroy()
        end
end

Try using the above script.

Ad

Answer this question