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.
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)
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.
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.