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)
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 :)