How do I set the Id of a shirt through a script?

I have already tried setting the Id via this;

local script (inside the gui)

local ShirtId
local PantsId
local TShirtId

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Parent.Enabled = false
	ShirtId = script.Parent.Parent.Parent.ShirtID.Text
	PantsId = script.Parent.Parent.Parent.PantsID.Text
	TShirtId = script.Parent.Parent.Parent["T-ShirtID"].Text
	game.ReplicatedStorage.AddCloathingEvent:FireServer(ShirtId, PantsId, TShirtId)
end)

server script (Inside the dummy)

game.ReplicatedStorage.AddCloathingEvent.OnServerEvent:Connect(function(plr, ShirtId, PantsId, TShirtId)
	script.Parent.Shirt.ShirtTemplate = ShirtId
	script.Parent.Pants.PantsTemplate = PantsId
	script.Parent["T-Shirt"].Graphic = TShirtId
end)

However, this did not work. The Id changed but the Shirt didn’t change. What I mean is that when I click on the Shirt in the explorer the property for the Id is the Id that I set but the Clothing that is on the dummy didn’t change it’s looks but it did change it’s properties.

Any help is appreciated!

1 Like

You need to use rbxassetid://ID_HERE

[Could we see what Pants,Shirt and TShirtID are?

They are variables used to store the Id that they player has typed into a TextBox.

Alright,

Have you tried to do so?
In your case, if those represent numbers, do:

script.Parent.Shirt.ShirtTemplate = "rbxassetid://"..ShirtId
script.Parent.Pants.PantsTemplate = "rbxassetid://"..PantsId
script.Parent["T-Shirt"].Graphic = "rbxassetid://"..TShirtId

It did not change the clothing. Same result. Changing it the properties but not on the dummy.

game.ReplicatedStorage.AddCloathingEvent.OnServerEvent:Connect(function(plr, ShirtId, PantsId, TShirtId)
	Workspace[plr.Name].Shirt.ShirtTemplate = "rbxassetid://"..ShirtId
	Workspace[plr.Name].Pants.PantsTemplate = "rbxassetid://"..PantsId
	Workspace[plr.Name]["Shirt Graphic"].Graphic = "rbxassetid://"..TShirtId
end)

I am not changing the players clothing but a dummies. It’s for a clothing mall. And rbxassetid didn’t work. Are there any other solutions?

Can you try this and tell me if it loads the clothing on the dummy?

game.ReplicatedStorage.AddCloathingEvent.OnServerEvent:Connect(function(plr, ShirtId, PantsId, TShirtId)
	script.Parent.Shirt.ShirtTemplate = "rbxassetid://9710269641"
	script.Parent.Pants.PantsTemplate = "rbxassetid://3408847792"
	script.Parent["T-Shirt"].Graphic = "rbxassetid://9543909224"
end)

An rbxassetid id is a different Id than a regular Id, so would there be any way to change something from a regular id to a rbxassetid id?

Can’t you just insert a shirt object into the dummy and set manually?

yes. It worked. So, it should be working for mine? I am using the Id from the browser and pasting it into the gui. were the Id’s you used rbxassetid ids? Because my ids that I am using and that most players would be using if grabbing the id, is not a rbxassetid id.

It’s for a clothing mall were players sell their clothing so I can’t really do it manually as the players would do it in game.

game.ReplicatedStorage.AddCloathingEvent.OnServerEvent:Connect(function(plr, ShirtId, PantsId, TShirtId)
	script.Parent.Shirt.ShirtTemplate = game:GetService("InsertService"):LoadAsset(ShirtId).Shirt.ShirtTemplate
	script.Parent.Pants.PantsTemplate = game:GetService("InsertService"):LoadAsset(PantsId).Pants.PantsTemplate
	script.Parent["T-Shirt"].Graphic = game:GetService("InsertService"):LoadAsset(TShirtId)["Shirt Graphic"].Graphic
end)
2 Likes

It comes up with this error;
Unable to cast string to int64

Oh wait!!! IT WORKED!!! THANKS!!! it just took a couple secs.