Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make an updated leaderboard?

Asked by 4 years ago

My leaderboard Value is the Weight's Level. But it won't update, even if the Weight's Value grow, the leaderboard's Value doesn't grow. It's because the leaderboard's Value was set when the Weight's Value was 1. I want to make an updated leaderboard so that when the weight updates ( grow ), the leaderboard also updates ( grow ). Here is my script for some infos:

local level = Instance.new("NumberValue")
    level.Name = "Level"
    level.Parent = leaderstats
    level.Value = game.StarterPack.Weight.Level.Value

So I created the leaderboard but when the game.StarterPack.Weight.Level.Value changes, the leaderboard doesn't. Thank you for reading this, please help me because I need to know how to make this to make my game.

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
game.Players.PlayerAdded:Connect(function(player)  -- You have to have the player
local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
local level = Instance.new("NumberValue")
    level.Name = "Level"
    level.Parent = leaderstats
    level.Value = player.Backpack.Weight.Level.Value

player.Backpack.Weight.Level.Value.Changed:Connect(function() -- Function when changed.
level.Value = player.Backpack.Weight.Level.Value
end)
end)

Everything in StarterPack is replicated to the player's backpack, so you need to get it from there. I didn't test this, so there are probably errors in it. I hope you get the idea.

0
or you can also use GetPropertyChangedSignal but yeah, I'll accept your answer TheKakYTArmy 125 — 3y
Ad

Answer this question