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

I'm trying to make a leaderboard, but the script just doesn't work right?

Asked by 10 years ago

LeaderStats = { "Kills", "Deaths", "Credits" }


function CreateLeaderboard(Player)

PlayerStats = Instance.new("IntValue", Player)
PlayerStats.Name = "leaderstats"    

for Counter = 1, #LeaderStats do
    NewLeaderstat = Instance.new("IntValue", PlayerStats)
    NewLeaderstat.Name = LeaderStats[Counter]
end

end



game.Players.PlayerAdded:connect(function(Player) print(tostring(Player) .. " has joined the game!") CreateLeaderboard(Player) end)


That's the script that I have to modify, but whenever I try to add something that changes the leaderstats values, the leaderboard disappears.

0
The leaderboard itsself is showing up until I actually put something in like a function that adds Credits every minute or every kill. ValkyrieLeonus 0 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago

LeaderStats = {"Kills", "Deaths", "Credits"}

game.Players.PlayerAdded:connect(function(Player)

local LeaderStat = Instance.new("IntValue", Player)
      LeaderStat.Name = "leaderstats"   

for i, v in pairs(LeaderStats) do

    local PlayerStat = Instance.new("IntValue", Player:FindFirstChild("leaderstats"))
    PlayerStat.Name = v

end

end)

Ad
Log in to vote
0
Answered by
Lacryma 548 Moderation Voter
10 years ago
LeaderStats = { "Kills", "Deaths", "Credits" }

function CreateLeaderboard(Player)
    PlayerStats = Instance.new("IntValue", Player)
    PlayerStats.Name = "leaderstats"   
    for Counter = 1, #LeaderStats do
        local NewLeaderstat = Instance.new("IntValue", PlayerStats)
            NewLeaderstat.Name = LeaderStats[Counter]
    end
end

game.Players.PlayerAdded:connect(function(Player) 
    print(tostring(Player) .. " has joined the game!") 
    CreateLeaderboard(Player) 
end)

You're overwriting the NewLeaderstat variable, so you need to add local to it.

Log in to vote
-1
Answered by 10 years ago

I heard that the leaderboard comes automatically, maybe you got some script you bought in the past that meant to show a leaderboard but it just deleted it, you need to search your workspace, and StarterGui and delete everything that incould in his name "Leaderboard", and try my working script: http://www.roblox.com/One-rank-leaderboard-item?id=170207688 (I putted it for sell). of course you can edit the script.

Answer this question