How to make the leaderstat value "Level" show up on the leaderboard?

I’m wondering how to make the player Levels show up on the leaderboard? I’m new to programming but my guess is that it’s something to do with not assigning the leaderstat value to a folder specifically named “leaderstat.” Any help is greatly appreciated, thanks!

game.Players.PlayerAdded:Connect(function(player)
	local level = Instance.new("IntValue", player)
	level.Name = "Level"
	level.Value = 1

	local exp = Instance.new("IntValue", level)
	exp.Name = "Current"
	exp.Value = 0

	local maxExp = Instance.new("IntValue", level)
	maxExp.Name = "Max"
	maxExp.Value = 100

	-- continous loop

	function additionXP()
		player.Level.Current.Value = player.Level.Current.Value + 25
	end
	
	while true do
		wait(30)
		additionXP()
		print("XP given!")
		if exp.Value >= maxExp.Value then
			level.Value = level.Value + 1
			exp.Value = 0
			maxExp.Value = maxExp.Value + 100
		end
	end
end)

*Edit, uploaded wrong script

Missing This:

local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player

Put That at the top under

Then Try thats my guess

1 Like

I’m assuming I’m going to have to reroute all the leaderstat values (the levels and exp) into the leaderstats folder? Adding that block of code didn’t change anything unfortnately.

Yeah you are, all the values in the “leaderstats” folder appear on the player’s leaderboard. If it’s parented directly to the player object and not to the “leaderstats” folder it won’t show up.

The second paramater here is the object the new instance is parented to, so you’ll have to replace the player variable with the leaderstats variable to parent it to leaderstats.

1 Like