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

How do I change leaderboard when a value changes?

Asked by 5 years ago

I have made a gui which consists of a textbox and a button, When the text is entered and button pressed it changed a value. I need this value to be updated in the leaderboard, But can't seem to have it change the leaderboard in game. The leaderboard is for a player rank in a certain group, And it works by inputting the group ID. Below is the code, Any help would be appreciated.

id = game.Workspace.tt.Value


game.Players.PlayerAdded:connect(function(D)
    repeat wait() until D:findFirstChild("leaderstats")
    local Rank = Instance.new("StringValue", D.leaderstats)
        Rank.Name = "Raiders"
         print (id)
    Rank.Value = D:GetRoleInGroup(id) 
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

To achieve this purpose you can do one of two things, a changed event or a GetPropertyChangedSignal function


Changed vs GetPropertyChangedSignal


the GetPropertyChangedSignal function, or the event returned by it fires when the property given as a parameter changes. While the changed event fires when almost any property of an instance changes. the GetPropertyChangedSignal function is prefered against the changed event when listening to only one property, as it can be needlessly expensive to listen to all property changes to listen for a change to a specific property. However, if it is something like an IntValue, StringValue, or ObjectValue object, use of the Changed event is prefered as it is shorter and there is only one logical property that you should be listening to changes on.


Application


For your purpose, I'm going to assume the value is a boolean value

BoolVal.Changed:Connect(function(newValue)
    if newValue == true then
        ...
    end
end)

If it isn't a "Value object", you can use the GetPropertyChangedSignal function like such:

local property = ""SomeProperty
Thing:GetPropertyChangedSignal(property):Connect(function()
    if Thing[property] = "Something" then
        ...
    end
end)
0
The value is an intvalue, as it is a group ID samual123456 2 — 5y
Ad

Answer this question