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

Display Cash in TextLabel how?

Asked by 5 years ago
Edited 5 years ago

I want to display the Cash Value in the TextLabel I saved it in the Local Player and tried to get it but he tells me that Leaderstats is not a valid member of Datamodel.Any one got a idea?


local plr = game.Players.LocalPlayer wait() local Cash = game.workspace.plr.leaderstats.cash.Value local plrCash = Cash:WaitForChild(plr.Name) script.Parent.YenAnzeige.Text = "Yen: "..plrCash.Yen.Value plrCash.Yen.Changed:connect (function() script.Parent.YenAnzeige.Text = "Yen: "..plrCash.Yen.Value end)
0
For starters you’ll want to get the leader stats just from the player, remove the “game.workspace” from Cash. I would only go as far as leaderstats.cash and call cash.Value when needed. Also I would look at your leaderstats hierarchy, I’m not sure that the player name is a child of your cash value ABK2017 406 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Your thinking process about how to accomplish this is correct. You get the stat's value from the player then you put that value into a TextLabel. I believe the only mistake in your code is getting the stat's value from leaderstats.

Depending on what leaderboard script you use, leaderstats isn't inside the player's model, rather it is inside the player itself and can be found under :

game.Players.LocalPlayer.leaderstats

From here, you can access the player's stats. For example, if you want to access their stat called "cash" you can find it under:

game.Players.LocalPlayer.leaderstats.cash

We can then assign the player's cash value to your variable then set your TextLabel to what the player's cash is:

local plrCash = game.Players.LocalPlayer.leaderstats.cash

script.Parent.YenAnzeige.Text = "Yen: "..plrCash.Yen.Value
plrCash.Changed:connect(function()
    script.Parent.YenAnzeige.Text = "Yen: "..plrCash.Yen.Value
end)

Ensure that when using game.Players.LocalPlayers you are using it inside a LocalScript, otherwise the script won't recognize it as valid and error.

If this solved your problem please accept my answer so both of us can gain reputation! Otherwise, leave a comment and I will further assist you :)

0
Aye, why didn't you mention the PlayerGui? DeceptiveCaster 3761 — 5y
Ad

Answer this question