Hi, i've been trying to make it so that every time a character spawns, their pants turn into this: https://www.roblox.com/catalog/3327167553/Green-Pajamas. However, I've been trying lots of different things but i'm way too inexperienced with Roblox Studio/Lua scripting to know what i'm doing (This is my first time attempting to script on Roblox/Lua ever). Where should I put my code to make this happen? What should my code be? What kind of script (local, regular, etc) do I need to use to make this happen?
My main attempt was this:
local function givePajamas(player)
local character = player.Character
if character then
-- look for pants
local pants = character:FindFirstChildOfClass("Pants")
-- create pants if they don't exist
if not pants then
pants = Instance.new("Pants", character)
end
-- reset pants content id
pants.PantsTemplate = "https://www.roblox.com/catalog/3327167553/Green-Pajamas"
end
end
givePajamas()
I put this code as a local script inside of StarterCharacterScripts. I tried to use the ROBLOX Dev API Reference on their website to help me out (which is where I got the bulk of this code from) but nothing has seemed to work.
Appreciate any help, thank you very much!

2 comments
Hey man! Thank you so much for the help!
It'd be great if you accepted this answer!