[Help picture] https://ibb.co/KWypMXD
I am trying to put the value of Output says that Player isn't a valid member of PlayerStats.
This is the code:
game.Players.PlayerAdded:Connect(function(plr) local f = Instance.new("Folder", plr) f.Name = "leaderstats" local coins = Instance.new("IntValue", f) coins.Name = "Coins" coins.Value = game.Players.Player.PlayerStats.Coins.Value end)
Pls tell me where in the code is wrong and correct it
Why are you doing game.Players.Player
. That's where the problem is coming from, probarly because "Player" doesn't exist inside Players.
You can simply avoid that easily, the PlayerAdded
event has a very useful paramater, it's the player that just joined. That "plr" variable, that you wrote, you can use that instead.
Also, you might not wanna use the second argument for Instance.new
which is the parent, it is deprecated but it still works causing some preformence issues. So just set the parent in a line by itself.
game.Players.PlayerAdded:Connect(function(plr) local f = Instance.new(“Folder”) f.Parent = plr f.Name = “leaderstats” local coins = Instance.new(“IntValue”) coins.Parent = f coins.Name = “Coins” coins.Value = plr.PlayerStats.Coins.Value end)