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

Atempt nil nil indext with leaderstats?

Asked by 1 year ago
Edited 1 year ago

Why am I getting an atempt nil index with leaderstats error in this script?

local button = script.Parent
local player = button:FindFirstAncestorOfClass("Player")
repeat
    player = button:FindFirstAncestorOfClass("Player")
    task.wait()
until player ~= nil

local debounce = true
button.MouseButton1Click:Connect(function()
    if debounce then
        debounce = false

        local leaderstats = player:WaitForChild("leaderstats")
        local Clicks = leaderstats:WaitForChild("Clicks")
        Clicks.Value += 1

        task.delay(0.5, function()
            debounce = true
        end)
    end
end)

local debounce2 = true
player.PlayerGui.Shop.ShopFrame.X1dot5.MouseButton1Click:Connect(function()
    local leaderstats = player:WaitForChild("leaderstats")
    local Clicks = leaderstats:WaitForChild("Clicks")
    local Coins = leaderstats:WaitForChild("Coins")

    if (Coins.Value >= 50) and debounce2 then
        debounce2 = false
        Clicks.Value += 1.5

        task.delay(0.5, function()
            debounce2 = true
        end)
    end
end)

Line 27 is the issue.

0
Which line? T3_MasterGamer 2189 — 1y
0
it is likely that there is something wrong with defining player Cooldoodle2019 4 — 1y

Answer this question