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