Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Delete all accessories script not working?

Hi, the title explains it. Also, it doesn't print the name of the hats.. It kinda just ignores it.

function getHair(plr, folder, gender)
	print(plr.Name.. " is a ".. gender)
	local hairs = serverStorage.Accessories:FindFirstChild(gender.."Hair")
	local hairChooser = math.random(1, #hairs:GetChildren())
	print(hairChooser)
	local chosenHair = hairs:FindFirstChild(gender..hairChooser)
	chosenHair.Handle.BrickColor = BrickColor.new(colours[math.random(1, #colours)])
	local clone = chosenHair:Clone()
	local clone2 = chosenHair:Clone()
	clone.Parent = folder
	local character = plr.CharacterAdded:Wait(2)
	for i,v in pairs(character:GetChildren()) do
		if v:IsA("Accessory") then
			print(v.Name.." is a hat")
			v:Destroy()
		else
			print(v.Name)
		end
	end
	clone2.Parent = character
	print("finished")
end

3 comments

0

is it a local or a server script?

0

you can get a player's character from this: plr.Character

0

I know. Also, this is a server script.

1 answer

Fixed it! All I had to do was use the a for loop properly.

This discussion is preserved as it was. New answers, comments, and votes are closed.