Help set shirt/pants using script

I’m trying to set shirt/pants using a script, but isn’t working (all permissions are enabled and no errors)

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, text, clothtype)
    local team = Player.plot.Value
    local plot = workspace:FindFirstChild(team)
    if clothtype == "Shirt" then
    	plot.Dummy.Shirt.ShirtTemplate = ("http://www.roblox.com/asset/?id=" .. text)
    	print(text)
    else
    	plot.Dummy.Pants.PantsTemplate = ("http://www.roblox.com/asset/?id=" .. text)
    	print(text)
    end
end)

Thanks

2 Likes

It should be workspace i think sir.

in which of all the "plot"s that are in the script?

I believe the problem here is that you’re inserting an ID and not an AssetID. Where are you getting the shirt/pants ID from? The website or…?

In the website, it’s a gui that ask the id and I put from the website

If you set ShirtTemplate from script it won’t change shirt because roblox probably has a function to get shirt template then applies shirt template as id if you try to set ShirtTemplate yourself in studio you will see id will change to another but there’s a way to do this which is using HumanoidDescription. Here’s an example:

local id = 6663030466
local Humanoid = workspace.Dummy.Humanoid 
local desc = Humanoid:GetAppliedDescription() 
desc.Shirt = id
Humanoid:ApplyDescription(desc)
1 Like

Website IDs will only work while you’re in Studio, but once you actually try to use it in-game the shirt won’t load.

Here’s how a Website ID looks like
image

It’s 6663030466; However when I insert this ID in a ShirtTemplate, it changes to 6663030462. That happens because Roblox retrieves the AssetID to display the template that was used to make this shirt.

This is a working solution and should be able to work around your issue - but the explanation above sums up why your code wasn’t previously working.

1 Like

It didn’t work, the dummy only switch the color to black

Can you show your updated code?

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, text, clothtype)
	local team = Player.plot.Value
	local plot = workspace:FindFirstChild(team)
	if clothtype == "Shirt" then
		local desc = plot.Dummy.Humanoid:GetAppliedDescription()
		plot.Dummy.HumanoidDescription.Shirt = text
		plot.Dummy.Humanoid:ApplyDescription(desc)
		print(text)
	else
		local desc = plot.Dummy.Humanoid:GetAppliedDescription()
		plot.Dummy.HumanoidDescription.Pants = text
		plot.Dummy.Humanoid:ApplyDescription(desc)
		print(text)
	end
end)

You should do desc.Shirt = text instead because desc is the HumanoidDescription you’re applying later not plot.Dummy.HumanoidDescription