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)

1PlayerStats = Instance.new("IntValue", Player)
2PlayerStats.Name = "leaderstats"   
3 
4for Counter = 1, #LeaderStats do
5    NewLeaderstat = Instance.new("IntValue", PlayerStats)
6    NewLeaderstat.Name = LeaderStats[Counter]
7end

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)

1local LeaderStat = Instance.new("IntValue", Player)
2      LeaderStat.Name = "leaderstats"  
3 
4for i, v in pairs(LeaderStats) do
5 
6    local PlayerStat = Instance.new("IntValue", Player:FindFirstChild("leaderstats"))
7    PlayerStat.Name = v
8 
9end

end)

Ad
Log in to vote
0
Answered by
Lacryma 548 Moderation Voter
10 years ago
01LeaderStats = { "Kills", "Deaths", "Credits" }
02 
03function CreateLeaderboard(Player)
04    PlayerStats = Instance.new("IntValue", Player)
05    PlayerStats.Name = "leaderstats"  
06    for Counter = 1, #LeaderStats do
07        local NewLeaderstat = Instance.new("IntValue", PlayerStats)
08            NewLeaderstat.Name = LeaderStats[Counter]
09    end
10end
11 
12game.Players.PlayerAdded:connect(function(Player)
13    print(tostring(Player) .. " has joined the game!")
14    CreateLeaderboard(Player)
15end)

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