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

Help with my script not sowing their leaderstats?

Asked by 8 years ago

This script is in a text label and is supposed to show the player his Money from the leaderboard. But this script does not work and the output isn't putting up errors. Please help

game.Players.PlayerAdded:connect(function(player)
    wait(1)
    player:WaitForDataReady()
    repeat wait() until player:FindFirstChild("leaderstats")
    if player.DataReady then
        if player:findFirstChild("leaderstats") then
            local Money = player.leaderstats.Money
            script.Parent.Text = Money
        end
    end
end)

1 answer

Log in to vote
0
Answered by
Im_Kritz 334 Moderation Voter
8 years ago

I see what you are trying to do, but you do not need all those checks and waits.

You need to define the Player and Leaderstats:

local TextLabel = script.Parent
local Player = TextLabel.Parent.Parent.Parent.Parent
local Stats = Player:WaitForChild('leaderstats')

Second, you need to create a change event and function:

Stats:WaitForChild('Money')Changed:connect(function()

end)

Third step is to code the change:

TextLabel.Text = stats.Money.Value

Last thing, is to put that all together:

local TextLabel = script.Parent
local Player = TextLabel.Parent.Parent.Parent.Parent
local Stats = Player:WaitForChild('leaderstats')

Stats:WaitForChild('Money')Changed:connect(function()
TextLabel.Text = stats.Money.Value
end)

Ad

Answer this question