Folder not being created in player file

I’m trying to create and attribute/stat system that makes a folder in the player’s file.
The folder is the place where the stats are being kept.

The problem is that this folder is never actually created and I don’t know why this is happening.

This is the code that’s supposed to make the folder and IntValue files:

game.Player.PlayerAdded:Connect(function(player)
local attr = Instance.new(“Folder”)
attr.Name = “Attributes”
attr.Parent = player

local health = Instance.new("IntValue")
health.Name = "Health"
health.Parent = attr

local speed = Instance.new("IntValue")
speed.Name = "Speed"
speed.Parent = attr

local attack = Instance.new("IntValue")
attack.Name = "Attack"
attack.Parent = attr

end)

You said ‘game.Player’, but it’s ‘game.Players’

Is there anything above this script?
I recommend replacing the game.Players.PlayerAdded connection with

local function onPlayerAdded(plr)

Then, below this event, add this:

for _, plr in ipairs(game.Players:GetPlayers()) do
    coroutine.wrap(onPlayerAdded)(plr)
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

Even if the issue turns out to be something else, this is the best way to do so, as if you were to have to require for example a module via assetId, this will take care of the player’s who joined while the module was loading.

Oh haha I’m blind

Thanks a lot!

No problem, happens to the best of us. Make sure to look out for any red underlines in your code, or else there will always be an error.

Thought I’d also add that you can condense the code when using Instance.new. The second parameter inside of it will actually specify the new instance’s parent. For example,

local attr = Instance.new(“Folder”, player)
attr.Name = “Attributes”

local health = Instance.new("IntValue", attr)
health.Name = "Health"