How to change a ShirtTemplate after a server has started?

Sorry if the title was a bit broad, but I was wondering how you would change the ShirtTemplate in a script? In my clothing home store, I made the clothing displays have a number value that would automatically change the buy shirts/pants scripts (I have that finished,) and the shirt on the model. Although, it does not change the ShirtTemplate correctly to show the change. How would I address this problem? Thanks!

1 Like

I’m not quite sure what you’re asking but try subtracting the ID of your shirt by one in the template until it loads right. The reason it (might) not be working is because you’re giving it the ID of the shirt and not the shirt template.

Sorry if that’s too vague.

Sorry for not being clear. I have a little system set up so that I change one number value that I would put the Shirt ID in (not the template,) so it can correctly change the promptPurchase in the buy script. I was wondering if it is possible to change the Shirt ID to a template ID for putting it onto the shirt on the mannequin. Would subtracting one be the best idea?

Just keep subtracting one until it works. :slight_smile:

If that doesn’t work, try adding one. It might take a while.

You could just load the asset of the shirt via InsertService and then apply its relevant ShirtTemplate.

local InsertService = game:GetService("InsertService")

-- ...

InsertService:LoadAsset(ShirtId):GetChildren()[1].ShirtTemplate -- Or whatever

LoadAsset(Id) on a shirt asset will return a Model with a Shirt object as its only child. You can fish into the model returned from InsertService::LoadAsset and then grab the ShirtTemplate from the Shirt object that’s in there, then apply it to whatever you need.

5 Likes