How to Update Values in the Leaderboard

Although I have a leaderboard in-game, the leaderboard does not update its values. Is there a way to achieve this?

leadre

local EXPVar = game.ReplicatedStorage.PlayerStats.EXP
game.Players.PlayerAdded:Connect (function(player)
	player.CharacterAdded:Connect (function(character)
		
		
------- PLAYER LEADERSTATS FOLDER -------------------------------------------------------
		local leaderstats = Instance.new("Folder")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = player
		
		local Power = Instance.new("IntValue")
		Power.Name = "Power"
		Power.Value = 0
		Power.Parent = leaderstats
		
		local EXP = Instance.new("IntValue")
		EXP.Name = "EXP"
		EXP.Value = EXPVar.Value
		EXP.Parent = leaderstats
		
	end)
end)

I need more detail on what you want, but to add and subtract values to your stats you just do,

player.leaderstats.Power.Value += 50

or

player.leaderstats.EXP.Value -= 75

1 Like

And is ExpVar a IntValue? Send me a picture of ReplicatedStorage

1 Like

Yes. I would like to add or subtract its values. But, to test it, I have an object that, when touched, adds value to it. However, that value does not convert onto the leaderboard’s value. Only the printed value.

test.Touched:Connect(function(partTouched)
print(“testtouch”)
EXPAdd.Value = EXPAdd.Value + 1
print(EXPAdd.Value)
wait(5)
end
end)

Screenshot 2023-12-18 105040

Is this code inside the leaderboard script?
Anyway why are you adding to ExpAdd variable,
wasn’t the variable you created for the data called EXP?

1 Like

i dont know if this issue has been fixed or not but im just gonna edit your leaderstats to make it abit shorter

local EXPVar = game.ReplicatedStorage.PlayerStats.EXP
game.Players.PlayerAdded:Connect (function(player)
	player.CharacterAdded:Connect (function(character)
		
		
------- PLAYER LEADERSTATS FOLDER -------------------------------------------------------
		local leaderstats = Instance.new("Folder",player)
		leaderstats.Name = "leaderstats"
		
		local Power = Instance.new("IntValue",leaderstats)
		Power.Name = "Power"
		Power.Value = 0
		
		local EXP = Instance.new("IntValue",leaderstats)
		EXP.Name = "EXP"
		EXP.Value = EXPVar.Value		
	end)
end)
1 Like

Putting all of the code inside of the leaderboard script seemed to work. Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.