Printing accessory name off of spawn

hi. straight to the point, im having trouble doing exactly whats in the title. rn, the script has a function of solely printing the name of the accessory. later i aim to change the handle’s ‘cantouch’ and ‘canquery’ properties off. here’s my script:

game.Players.PlayerAdded:Connect(function(plr)
	
	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	ls.Parent = plr
	
	local credits = Instance.new("IntValue")
	credits.Name = "credits"
	credits.Value = 0
	credits.Parent = ls
	
	local using = Instance.new("StringValue")
	using.Name = "ability"
	using.Value = "default"
	using.Parent = ls
	
	local equipped = Instance.new("StringValue")
	equipped.Parent = plr
	equipped.Value = "default"
	equipped.Name = "equipped"
	
	plr.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetDescendants()) do
			if v:IsA("Accessory") then
				print(v.Name)
			end
		end
	end)
end)

when i remove the

if v:IsA("Accessory") then

part, it prints every name of every descendant just fine. but the second i put it back in (keep in mind i have 3 accessories on my avatar, including hair) it wont print. pls help me out

edit: this is a server script inside of ‘ServerScriptService’

You should use CharacterAppearanceLoaded instead. It waits until the player’s full character appearance has been inserted.

player.CharacterAppearanceLoaded:Connect(function(character)
	for index, child in ipairs(character:GetChildren()) do
		if child:IsA('Accessory') then
			print(child.Name)
		end
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.