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

How do you find how many of the same objects you have in the players character?

I am trying to do, if the player's character has 2 or more objects named "SpikeHair" then it does certain code.

--More code up here
if Player.Character.SpikeHair == #2 then
		--Code here
	end

1 answer

✓ Accepted answer

local num = 0 -- makes a global variable
for i,v in pairs(Player.Character:GetChildren()) do -- iterates thruout character
	if v.Name = "SpikeHair" then -- makes a condition if the name is SpikeHari
		num = num+1 -- counts it
	end
end
if num >= 2 then -- if the hair is more than 2
--code here
end

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