So, im trying to reference a specific leaderstat. i tried "local stats = player:WaitForChild("leaderstats")" But that did not work as i am trying to reference a SPECIFIC leaderstat. Please help. (i have 2 leaderstats and i'm trying to reference only one of them)
You need to remember what you named your Leaderstats and the Stat you want to reference.
local Player = game.Players.LocalPlayer local Leaderstat = Player:WaitForChild("leaderstats") -- // If "leaderstat" is what you named your leaderstat. local Stat = Leaderstat["StatName"] -- // Replace "StatName" with the stat you want to reference.
Hello! I can see your problem! leader stats is a folder in a player that holds certain values, like a box of books. Thus, you need to make sure it gets the value inside the box or the folder!
What you were doing before was trying to get the folders value. The folder does not have a property called Value, so getting a folders value would be impossible. What you need to do is get a value inside the folder (aka money, XP, etc) and use that!
This is what you tried to do:
--This would not work because of this local Stat = player:WaitForChild("leaderstats") Stat.Value = 2--This would not work properly because a folder does not have a value
This is what you should do!
local Stat = player.leaderstats:FindFirstChild("Your stat name")--Change this to money, XP, etc Stat.Value = 5--This would work because, assuming your using an IntValue, the object has a ----value
I hope this helps you! If you have any questions, comment below!
Best
TheLastHabanero