i’m making a character customization gui where a player type a shirt ID in a textbox and the text from the textbox get converted into a shirt template id. i tried many many thing but none of them worked.
an example of this is the customization of Ro Piece
You can achieve this by getting the text within a textbox and then changing the shirt id of the character. Though if you want everyone to see the shirt change you may need to use RemoteEvents.
yes i tried doing that but the problem is the ShirtId because if you use the id the player wrote in the textbox it doesn’t work (because the id you take from the roblox site is different from the tamplate id you need inside the ShirtTemplate)
-- Client
RemoteEvent:FireServer(tonumber(Textbox.Text))
-- Server
RemoteEvent.OnServerEvent:Connect(function(Player, ShirtId)
local Model = game:GetService("InsertService"):LoadAsset(ShirtId)
if Model:FindFirstChildOfClass("Shirt") then
if Player.Character:FindFirstChildOfClass("Shirt") then
Player.Character:FindFirstChildOfClass("Shirt"):Destroy()
end
Model.Shirt.Parent = Player.Character
end
Model:Destroy()
end)
This script worked for me. Below is the full scripture:
-- LOCAL SCRIPT
local TextBox = -- put wherever your text box is here
local RemoteEvent = -- put wherever your remote event is here
TextBox.FocusLost:Connect(function(enterPressed)
if enterPressed then -- if the Enter button was pressed
RemoteEvent:FireServer(TextBox.Text)
end
end)
-- SERVER SCRIPT --
local RemoteEvent = -- the same RemoteEvent from before
RemoteEvent.OnServerEvent:Connect(function(player, ShirtId)
local Character = player.Character or player.CharacterAdded:Wait()
local Shirt = Character:FindFirstChildWhichIsA("Shirt")
if not Shirt then -- if the shirt object does not exist in character
local NewShirt = Instance.new("Shirt")
Shirt = NewShirt
Shirt.Parent = Character
end
Shirt.ShirtTemplate = "rbxassetid://" .. ShirtId
end)