What is wrong with my simple leadertstats script?

Hey, I’m in need of some help with me leaderstats script. i’m a bit confused on what could have gone wrong since there is no error in the output whatsoever.

my script:

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "Leaderstats"
	
	
	local Strength = Instance.new("IntValue",leaderstats)
	Strength.Name = "Strength"
	
	
end)

thanks for reading,

any help is appreciated!

kimathi.

make it a NumberValue instead of IntValue

2 Likes

wait no I am stupid you wrote Leaderstats in stead of leaderstats

2 Likes

It will only show up if it is called leaderstats all lower case if I am right. Also you forgot to say what is the issue and what you want to achieve, if this helped you make sure to make it Solution

4 Likes

You have capital “L” in leaderstats.

1 Like

yes you are right ot only shows if its leaderstats

also why are you talking to yourself

I just accidently replied to my own post is something wrong with that?

1 Like

nope there is nothing wrong with that :sweat_smile: but its definetely weird

1 Like

You are correct and should be the solution, but I’ll mention a few other things for @OP.

  • I recommend using GetService("Players") instead of .Players as if you accidentally rename your Players service you will error, but even then, it is genrally good practice to use GetService than direct indexing

  • Do not use the 2nd parameter of Instance.new, it can be slower than just parenting the value at the end, depending on how many properties to set but generally it’s still good practice not the use the 2nd parameter unless you’re only making a new instance and parenting it without setting any properties.

Overall, I think with all the changes this would be a better way to do the script

local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Strength = Instance.new("IntValue")
	Strength.Name = "Strength"
	Strength.Parent = leaderstats	
end)
1 Like