Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

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

3 answers

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.