ShirtIDChange Not Working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to change the shirt from player.

  2. What is the issue? It all worked, but it gives a blanked shirt.
    image

  3. What solutions have you tried so far? I tryed a lot, even a outer shirt id. but it will not work. and if I put this text ‘http://www.roblox.com/asset/?id=2489164735’ myself in the shirt id, it work dirrectly. But I see the Id changed itself. Can someone help me? I want this shirt ID: 2489164735

local Box = script.Parent.Parent.IDBox
local db = false
local player = game.Players.LocalPlayer
local Character = game.Workspace:FindFirstChild(player.Name)
local MarketplaceService = game:GetService("MarketplaceService")

Box.Text = ''

script.Parent.MouseButton1Click:Connect(function()
	if db == false then
		db = true
		Box.TextEditable = false
		local OrriginalText = Box.Text
		Box.Text = 'Loading'
		wait(0.5)
		
		local success, response = pcall(function()
			local text = tonumber(OrriginalText)
			local stuf = MarketplaceService:GetProductInfo(text)
			if stuf.AssetTypeId == 11 then
				print(stuf.AssetId)
				Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="..stuf.AssetId
				Box.Text = 'Correct changed!'
			else
				Box.Text = 'No Shirt!'
			end
		end)
		if not success then
			Box.Text = 'No Correct ID!'
		end
		
		wait(2)
		Box.Text = OrriginalText
		db = false
		Box.TextEditable = true
	end
end)
1 Like

Did you put the string “” in your script? I don’t see them before and after the id/link
Like this:

Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=" ..stuf.AssetId

And not:

Character.Shirt.ShirtTemplate = http://www.roblox.com/asset/?id='..stuf.AssetId

If you did add the string “”, I encountered this sometimes in the past, some clothes did change and some changed to blank and failed to load.
Only when I used InsertService:LoadAsset(assetId) to get the model with the clothing in it, it worked for me.
InsertService:LoadAsset(assetId)

For instance:
To get the shirt:

local assetId = 123456 --Random id
local success, shirt = pcall(function()
    return game:GetService("InsertService"):LoadAsset(assetId) --Get the model with the asset
end)
if success then --If it loaded successfully
    shirt = shirt:FindFirstChildOfClass("Shirt")
    --Destroy the current shirt and replace it with the new one
else --Shirt wasn't loaded successfully
    warn(shirt) --Warn the error that caused the loading to fail.
end

@kalabgs yeah, as far as I know, it doesn’t matter whether you use the longer one or the shorter one.

2 Likes

or “rbxasseitd://”…id can be used too since its shorter

3 Likes

I think you forgot to end your string here

2 Likes

no, I got it, see image:

1 Like

I already tryed that to. and it do not work.

1 Like

So does it work for you now?

If it still doesn't work

Did you try to use InsertService:LoadAsset()? It’s a bit different than changing the ID, and solved it for me.

2 Likes

but the thing is. it all works. I will import a video. give me minute

1 Like

If it all works then no need to send a video :slightly_smiling_face:.
I just didn’t understand whether you managed to fix it or not.

2 Likes

wait, look:
so I put this id in it MANUALY:
image
and I get this id back:
image
Do you know why? Becuase that is the problem.

1 Like

now do I get this error:

1 Like

Oh, you are changing the Shirt If from a local script.
That’s a different case, in this case, you can’t use InsertService.

Although I don’t get something, is it intentional that you change the shirt Id from the client (local scripts)?

When you change clothing from Local scripts, only you can see the different clothes, other players will see you normally (without a different shirt).

If not, I suggest you to use RemoteEvents to change the shirt from a script.

2 Likes

Using what @LightningLion58 said:

LocalScript
local Box = script.Parent.Parent.IDBox
local db = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ChangeShirt = ReplicatedStorage:WaitForChild("ChangeShirt")

Box.Text = ''

script.Parent.MouseButton1Click:Connect(function()
    if db == false then
	    db = true
	    Box.TextEditable = false
    	local OrriginalText = Box.Text
	    Box.Text = 'Loading'
	    wait(0.5)
	    local Id = tonumber(OrriginalText)
	    local Bool = ChangeShirt:InvokeServer(Id)
	    Box.Text = Bool
	    wait(2)
	    Box.Text = OrriginalText
	    db = false
    	Box.TextEditable = true
	end
end)
Script
local MarketplaceService = game:GetService("MarketplaceService")
local Insert = game:GetService("InsertService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ChangeShirt = ReplicatedStorage:WaitForChild("ChangeShirt")

function Change(Player,ShirtId)
    local Return = "Error"
    local success,stuf = pcall(function()
    	return MarketplaceService:GetProductInfo(ShirtId)
	end)
    if success then
	    if stuf.AssetTypeId == 11 then
		    print(stuf.AssetId)
		    local Shirt = Player.Character:FindFirstChildOfClass("Shirt")			
            if Shirt then		Shirt:Destroy()		end
		    local Obj = Insert:LoadAsset(ShirtId):GetChildren()[1]
	    	Obj.Parent = Player.Character
    		Return = 'Correct changed!'
		else
		    Return = 'No Shirt!'
	    end
    else
    	Return = 'No Correct ID!'
	end
    return Return
end
ChangeShirt.OnServerInvoke = Change

And put a RemoteFunction called “ChangeShirt” in ReplicatedStorage.

1 Like

thanks. I hope it works now XD

thanks, it works! Hope you have a nice day.

You’re welcome, happy to help ^ - ^

1 Like