LeaderStats = { "Kills", "Deaths", "Credits" }
function CreateLeaderboard(Player)
1 | PlayerStats = Instance.new( "IntValue" , Player) |
2 | PlayerStats.Name = "leaderstats" |
3 |
4 | for Counter = 1 , #LeaderStats do |
5 | NewLeaderstat = Instance.new( "IntValue" , PlayerStats) |
6 | NewLeaderstat.Name = LeaderStats [ Counter ] |
7 | 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.
LeaderStats = {"Kills", "Deaths", "Credits"}
game.Players.PlayerAdded:connect(function(Player)
1 | local LeaderStat = Instance.new( "IntValue" , Player) |
2 | LeaderStat.Name = "leaderstats" |
3 |
4 | for i, v in pairs (LeaderStats) do |
5 |
6 | local PlayerStat = Instance.new( "IntValue" , Player:FindFirstChild( "leaderstats" )) |
7 | PlayerStat.Name = v |
8 |
9 | end |
end)
01 | LeaderStats = { "Kills" , "Deaths" , "Credits" } |
02 |
03 | function 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 |
10 | end |
11 |
12 | game.Players.PlayerAdded:connect( function (Player) |
13 | print ( tostring (Player) .. " has joined the game!" ) |
14 | CreateLeaderboard(Player) |
15 | end ) |
You're overwriting the NewLeaderstat variable, so you need to add local to it.
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.