How to tag someone when join and using that tag to set attributes

hello, im very new to tags, so i try to make something when someone joins get a tag and the attributes, like i say in the title, but i dont know how, and why i want to have a tag for setting attributes?, well you see, i have a combat system, but the thing, i have dummys and i put the same script to set the attributes, so im tired of it when i need to manually put attributes inside of a script of each dummy, so how i manage that?, can someone give me a example?

this is what i try by far using an already existing script that do some other stuff when player is added:

local bruh = game:GetService("CollectionService")

function normals_atribute(part)
	print("attributes_added to ".. part.Name)
	part:SetAttribute("lol", false)

	local plr = game.Players:GetPlayerFromCharacter(part)
	if plr then
		plr:SetAttribute("balls", false)
	end
end

for _, part in bruh:GetTagged("Alive_Atributes") do
	if part:IsA("Model") then
		normals_atribute(part)
	end
end


-- Player leaving and joining
local Players = game:GetService("Players")

function PlayerAdded(Player)
	local plr = Player
    --a little bit of code

	local function charLoaded(char)
    --more boring code
		bruh:AddTag(char, "Alive_Atributes")-- tag added
	end
	if Player.Character then
		charLoaded(Player.Character)
	end
	Player.CharacterAdded:Connect(charLoaded)
end

for _, Player in ipairs(Players:GetPlayers()) do
	task.spawn(PlayerAdded, Player)
end

Players.PlayerAdded:Connect(PlayerAdded)
1 Like

It seems like you only check for Alive_Atributes once. Also, gotta respect the unique variable names. “bruh” is definitely an odd thing to name CollectionService!

2 Likes

a lot of the times im very lazy to putting names at everything in roblox studio, so i put anything in my mind, even slurs