How to detect if a player is wearing a shirt, and add one if they don't

So basically I just want it to detect if the character has a shirt, and if they don’t I want it to add one for them. I used this:

if character.Shirt ~= nil then
	shirt = character:WaitForChild("Shirt")
else
	shirt = Instance.new("ShirtGraphic") -Or Shirt. Idk which one to use.
end

How can I do that?

local shirt = character:FindFirstChildOfClass("Shirt"); --This will return nil if there's no shirt found
if not shirt then
	shirt = Instance.new("Shirt");
	shirt.Parent = character;
end
5 Likes

Do I have to put the semicolons?

1 Like

No, it’s just something I do out of habit from other programming languages. They don’t do anything.

3 Likes