Creating attributes value for all players

Hello I am new to scripting and sometimes “Local Script” and “Server Script” thingy can confuse me. I want to add 3 variables to all players in game and Server Script can access it. For example I want to add “style”, “armor”, and “hat” variable in String for the players, I tried to put those variables inside Server Storage. However, when I changed it, it affected every players, what I want is when I change the value of “style” variable, it only affects a player which I assigned to with Server Script not Local Script. Any help would be great, thanks!

You can achieve this with either StringValue instances or attributes.

StringValues:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local value = Instance.new("StringValue")
	value.Name = "Name" --Choose stat name.
	value.Value = ""
	value.Parent = player
end)

Atrributes:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player:SetAttribute("AttributeName", "AttributeValue")
end)

These are server script examples.

2 Likes

Thank you so much, it is working :smiley: