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

Points are given to the player in the leaderboard, but not working?

Asked by
Jephi 42
8 years ago
local intv = 1
local pointsGiven = 1

----------------------------------------------------


function pointGive()
    while wait(intv) do
        for _, player in ipairs(game.Players:GetPlayers()) do
            local leaderstats = Instance.new("Model", player)
            leaderstats.Name = "leaderstats"
            local points = Instance.new("NumberValue", player.leaderstats)
            points.Name = "Points"

            if player:FindFirstChild("leaderstats") then
            player.leaderstats.Points.Value = player.leaderstats.Points.Value + pointsGiven
            end
        end
    end
end

game.Players.PLayerAdded:connect(pointGive)

This should show up a column in the leader board saying "Points" and the player should be awarded 1 point every second. This isn't doing what I want it to do. I also want this to save for next time the players join.

0
What output are you getting? What debugging have you done? BlueTaslem 18071 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

The problem here is that you already had a leaderboard, and then you where creating a new one, constantly.

Try replacing it with this:

local intv = 1
local pointsGiven = 1

----------------------------------------------------


function pointGive()
    while wait(intv) do
        for _, player in ipairs(game.Players:GetPlayers()) do
            if player:FindFirstChild("leaderstats") then
            player:WaitForChild('leaderstats'):WaitForChild('Points').Value = player.leaderstats.Points.Value + pointsGiven
        else
        local leaderstats = Instance.new("Model", player)
            leaderstats.Name = "leaderstats"
            local points = Instance.new("NumberValue", player.leaderstats)
            points.Name = "Points"
            end
        end
    end
end

game.Players.PLayerAdded:connect(pointGive)
Ad

Answer this question