Function gets called, doesn't do anything?

the title is very clear. I call a function when a character is added(I checked it with debugging tools, it does get called) however, it doesn’t do anything.

local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local function addTag(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local humrootpart = char:WaitForChild("HumanoidRootPart")
	CollectionService:AddTag(humrootpart, "Egg")
    print(CollectionService:GetTags(humrootpart))
end

Players.PlayerAdded:Connect(function(plr)
	plr:LoadCharacter()
	addTag(plr)
end)

Can you put a print in the PlayerAdded event and tell me if it prints?

Actually nevermind.

Does this print? What does it print?

Nope, prints nothing. I just did that for testing purposes

How about this?

Doesn’t print as well. Is this because its a LocalScript?

Yeah. AFAIK PlayerAdded doesn’t work in LocalScripts.
And PlayerAdded SOMETIMES doesn’t work in Studio.

1 Like
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")

local LocalPlayer = Players.LocalPlayer

local function addTag(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local humrootpart = char:WaitForChild("HumanoidRootPart")

	CollectionService:AddTag(humrootpart, "Egg")
    print(CollectionService:GetTags(humrootpart))
end

LocalPlayer:LoadCharacter()
addTag(LocalPlayer)

script runs when the player joins because it is a local script