Why is this not interpreted as a correct ID?

I’m trying to create a change shirt script using a custom ID put in a textbox. However, when I merge the user inserted ID with the base ‘‘rbxassetid://’’, it doesn’t work.
Heres the script:

local ShirtID = game.StarterGui.CustomizationMenu.AnimationFrame.AccessoryID.Text
local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEvent"
local IDDefault = "rbxassetid://"

function GiveUni(plr)
	ShirtID = game.StarterGui.CustomizationMenu.AnimationFrame.AccessoryID.Text
	local Shirt = IDDefault .. ShirtID
	--local Pants = "rbxassetid://398633811"
	local character = plr.Character
	local shirt = character.Shirt
	--local pants = character.Pants
	shirt.ShirtTemplate = Shirt
	--pants.PantsTemplate = Pants

1 Like

Have you tried adding a single digit to the id?

Theres a difference between the ID in the URL and the asset ID.

1 Like

what do you mean by single digit to the ID? btw when i tried doing the same thing but replacing ShirtID with a number in quotes like this: “123” it displayed the final one as “rbxassetid://123” but when I use a variable number that is 100% a string, it still doesnt work.

Remove all the spaces in IDDefault .. ShirtID.

After this change you should have IDDefault..ShirtID.

The URL id is different than the asset id, you need to add a digit to the end, for example if the URL is 12345, the asset id would be 12346

so how would I add a 1 to the string, would lua do it for me or do i have to convert to int then back to string?

Attempt this, it should work if I am not mistaken

It doesn’t work, and when I add a 1 to the ID it turns the shirt into an entirely different shirt instead of the one I want.

When I got rid of the spaces the ID still wasn’t included as part of the string.

You are referencing game.StarterGui instead of game.Players.LocalPlayer.PlayerGui.

Essentially, when a new client is created/a new character is found (you can set this in the settings of the ScreenGui), the game will copy all items from game.StarterGui and paste it in the newly joined player’s PlayerGui, which can be found through game.Players.LocalPlayer.PlayerGui.

What you are currently doing is attempting to grab the value from your TextLabel in the global StarterGui, but there is no value so the script cannot find anything. You should instead be grabbing the GUI through the player’s PlayerGui that is currently on their screen.

Hopefully this helps!

1 Like

when I replaced the top line with this it gave me an index nil, do I have to do this inside a local script?

yes, I suggest learning about lua first, using LocalPlayer inside of local scripts only is common knowledge

i was just wondering if there was a way around doing this, since it conflicts with my script