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
print(type(ShirtID))
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
end
Event.OnServerEvent:Connect(GiveUni)
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.
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.