Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

LeaderBoard Problems? Entering an existing value

[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

3 comments

1

R u sure the output is not the opposite? "PlayerStats isn't a valid member of Player"

0

Yah it should be like that

0

oh yh the output is the opposite

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.