Help doesn't set the shirt and pants in a script

I put a script to put a shirttemplate and pantstemplate but doesn’t work, can someone help me?

Script:

local shirtIDs = {
	"11939149226",
	"12194571961",
	"6668635237",
	"17205592737"
}

local pantsIDs = {
	"11939157230",
	"11942062856",
	"6669511764",
	"11942062856"
}

local shirt = script.Parent.Shirt
local pants = script.Parent.Pants

local shirtSelected = shirtIDs[math.random(0, #shirtIDs)]
local pantsSelected = pantsIDs[math.random(0, #pantsIDs)]

shirt.ShirtTemplate = "rbxassetid://"..tostring(shirtSelected)
pants.PantsTemplate = "rbxassetid://"..tostring(pantsSelected)

Hmm, it looks like your code is correct…

Maybe try parenting the clothes to something else (i.e the script itself) then back to the character? Maybe they just needed to be reloaded. It’s also possible that the ROBLOX asset delivery servers were wonky right then.

If that doesn’t work, let me know.

AFAIK roblox clothes hates being told to be set to a rbxasetid!
try

"http://www.roblox.com/asset/?id=" .. tostring(x)
Side note; roblox arrays do not start at 0 unless specifically told! i.e

e = {
[0] = "hi",
[1] = "e"
}

if i did e[0] it would print “hi”

e = {
"hi"
"e"
}

if i did e[0] it would either throw hands with me or say nil.

You have to use ‘free use’ items. I think you can also use ones you own.
I know not all are free to use, these work…


local shirtIDs = {
	"3670737337" 
}

local pantsIDs = {
	"144076759"
}

local shirt = script.Parent.Shirt
local pants = script.Parent.Pants

local shirtSelected = shirtIDs[math.random(1, #shirtIDs)]
local pantsSelected = pantsIDs[math.random(1, #pantsIDs)] --0 would = nil

shirt.ShirtTemplate = "rbxassetid://"..shirtSelected
pants.PantsTemplate = "rbxassetid://"..pantsSelected --this is already a string

If those two are not working, I think I own them… They work for me.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local function createClothing()
			local shirt
			local pants

			local shirtIDs = {
				"11939149226",
				"12194571961",
				"6668635237",
				"17205592737"
			}

			local pantsIDs = {
				"11939157230",
				"11942062856",
				"6669511764",
				"11942062856"
			}

			if character:FindFirstChild("Shirt") then
				print("Shirt found")
			elseif character:FindFirstChild("Pants") then
				print("Pants found")
			else
				shirt = Instance.new("Shirt", character)
				pants = Instance.new("Pants", character)

				shirt.Name = "Shirt"
				pants.Name = "Pants"
			end

			local shirtSelected = shirtIDs[math.random(1, #shirtIDs)]
			local pantsSelected = pantsIDs[math.random(1, #pantsIDs)]

			return shirtSelected, pantsSelected
		end

		local function applyAppearance()
			local shirtId, pantsId = createClothing()

			local humanoid = character:WaitForChild("Humanoid")
			local appearance = humanoid:GetAppliedDescription()

			appearance.Shirt = tonumber(shirtId)
			appearance.Pants = tonumber(pantsId)

			humanoid:ApplyDescription(appearance)
		end

		applyAppearance()
	end)
end)

Add this to serverscriptservice. It should do the trick, I tested it in studio.