How would i go about giving the player a shirt if they dont have one?

So I have this shirt giver table, but if the player does not have a shirt it does not give it to them obviously, but I dont know how to give the player a shirt any help?

local bunchOfShirts = {
    [1] = "rbxassetid://10248083", --Default Shirt
    [2] = "rbxassetid://1178599385", -- Army green
	[3] = "rbxassetid://2397305859", --Guess reckless
	[4] = "rbxassetid://885261392", --Hawaiian shirt
	[5] = "rbxassetid://3144003341", --JackMercando shirt
	[6] = "rbxassetid://3152639503", -- Osito Pink Shirt
	[7] = "rbxassetid://668772580", -- Red Jacket
	[8] = "rbxassetid://554084413", -- Supreme Worldflags
	[9] = "rbxassetid://2970602368", -- Tank top
	[10] = "rbxassetid://2072675468", -- Tommy hilfiger
	[11] = "rbxassetid://2641146107", -- Tour Jacket
	[12] = "rbxassetid://604130756", -- Yellow puffer
	[13] = "rbxassetid://3404963397", -- Yellow puffer
}

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:Connect(function(character)       
		local d = character:WaitForChild("Shirt")
		local val = player:WaitForChild("leaderstats").Shirt.Value
        if val >= 1 then
            wait(1)
			if val >= #bunchOfShirts then
				d.ShirtTemplate =  bunchOfShirts[#bunchOfShirts]
			else
				d.ShirtTemplate =  bunchOfShirts[val]
			end
        end
    end)
end)

Hey, Pooglies!

You can do this pretty simply,

Use Instance.new() this will work fine.

local shirt = Instance.New("Shirt")
shirt.ShirtTemplate = #bunchOfShirts
shirt.Parent = character

Hope this works!
Happy developing,

  • DrBaja