Can't get the player in a server script

What @MEsAv2 said is right, and judging by your code above is probably what the issue is - try this

local function playerAdded(player)
	local attributes = Instance.new("Folder")
	attributes.Name = "Attributes"
	attributes.Parent = player

	local attack = Instance.new("IntValue")
	attack.Name = "Attack"
	attack.Value = 5
	attack.Parent = attributes
end

--Incase player joined earlier than this script ran
for _, player in ipairs(Players:GetPlayers()) do
	task.spawn(playerAdded, player)
end

Players.PlayerAdded:Connect(function(playerAdded)

(Also as a side note you should not do Instance.new(“Folder”, player) if you are going to be changing attributes of the new instance as it is not optimised)

2 Likes