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

Leaderboard coin giver brick is not adding coins to the leaderboard, why not?

Asked by 7 years ago

I don't know what the problem is, but here is the leaderboard script:

game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new('IntValue', plr)
    stats.Name = 'leaderstats'
    local coins = Instance.new('IntValue', stats)
    coins.Name = 'Coins'
    coins.Value = 0
    local diamonds = Instance.new('IntValue', stats)
    diamonds.Name = 'Diamonds'
    diamonds.Value = 0
    local wins = Instance.new('IntValue', stats)
    wins.Name = 'Wins'
    wins.Value = 0
    local exp = Instance.new('IntValue', stats)
    exp.Name = 'Exp'
    exp.Value = 0
    local level = Instance.new('IntValue', stats)
    level.Name = 'Level'
    level.Value = 0
end)

And then here is the Part that i inserted the script into to give coins onto the leaderboard:

local brick = script.Parent

function onTouched(hit)
    for i,player in ipairs(game.Players:GetPlayers()) do
        if player.Character then
            local stat = player:FindFirstChild("leaderstats")
            if stat then
                player.leaderstats.Coins.Value = player.leaderstats.Money.Value +5
                brick:Destroy()
            end
        end
    end
end


brick.Touched:connect(onTouched)

Does anyone know what the problem may be?

1 answer

Log in to vote
0
Answered by 7 years ago

You put player.leaderstats.Coins.Value = player.leaderstats.Money.Value +5 (Money instead of coins)

player.leaderstats.Coins.Value = player.leaderstats.Coins.Value +5
0
Oh, I didn't see that, haha thanks! Supergamerboy1995 129 — 7y
Ad

Answer this question