-- Avatar Customization Script
-- This script should be placed in the GUI Button handlers, or a LocalScript
inside the GUI.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- GUI Elements (Buttons)
local changeShirtButton = script.Parent:WaitForChild("ChangeShirtButton")
local changePantsButton =
script.Parent:WaitForChild("ChangePantsButton")
local changeHatButton = script.Parent:WaitForChild("ChangeHatButton")
local changeHeadButton =
script.Parent:WaitForChild("ChangeHeadButton")
-- Avatar parts to customize
local shirtCatalog = {"rbxassetid://123456789", "rbxassetid://987654321"}
-- Add shirt asset IDs
local pantsCatalog = {"rbxassetid://112233445", "rbxassetid://556677889"}
-- Add pants asset IDs
local hatCatalog = {"rbxassetid://667788990", "rbxassetid://112233445"} --
Add hat asset IDs
local headCatalog = {"rbxassetid://998877665", "rbxassetid://554433221"}
-- Add head asset IDs
local shirtIndex = 1
local pantsIndex = 1
local hatIndex = 1
local headIndex = 1
-- Function to change the player's shirt
local function changeShirt()
local shirt = character:FindFirstChildOfClass("Shirt") or
Instance.new("Shirt")
shirt.Parent = character
shirt.ShirtTemplate = shirtCatalog[shirtIndex]
-- Move to next shirt in catalog, loop around if out of range
shirtIndex = shirtIndex + 1
if shirtIndex > #shirtCatalog then
shirtIndex = 1
end
end
-- Function to change the player's pants
local function changePants()
local pants = character:FindFirstChildOfClass("Pants") or
Instance.new("Pants")
pants.Parent = character
pants.PantsTemplate = pantsCatalog[pantsIndex]
-- Move to next pants in catalog, loop around if out of range
pantsIndex = pantsIndex + 1
if pantsIndex > #pantsCatalog then
pantsIndex = 1
end
end
-- Function to change the player's hat
local function changeHat()
local existingHat = character:FindFirstChildOfClass("Accessory")
if existingHat then
existingHat:Destroy() -- Remove the existing hat
end
local hat = Instance.new("Accessory")
local hatPart = Instance.new("Part")
hatPart.Name = "Handle"
hatPart.Size = Vector3.new(1, 1, 1)
hatPart.Anchored = false
hatPart.CanCollide = false
hatPart.CFrame = character.Head.CFrame
hatPart.Parent = hat
hat.AttachmentPoint = Vector3.new(0, 0, 0)
hat.Parent = character
-- Set the hat texture (using catalog ID)
hat.TextureID = hatCatalog[hatIndex]
-- Move to next hat in catalog, loop around if out of range
hatIndex = hatIndex + 1
if hatIndex > #hatCatalog then
hatIndex = 1
end
end
-- Function to change the player's head
local function changeHead()
local newHead = Instance.new("Head")
newHead.Parent = character
newHead.MeshId = headCatalog[headIndex]
-- Move to next head in catalog, loop around if out of range
headIndex = headIndex + 1
if headIndex > #headCatalog then
headIndex = 1
end
end
-- Button Event Listeners
changeShirtButton.MouseButton1Click:Connect(changeShirt)
changePantsButton.MouseButton1Click:Connect(changePants)
changeHatButton.MouseButton1Click:Connect(changeHat)
changeHeadButton.MouseButton1Click:Connect(changeHead)