As in a button in an inventory. I do not know how I would make it so that on click, my character equips a hat, or a package, etc.
COMMUNITY QUESTION
How do I create a gui button that changes what my character is wearing?
2 answers
Make sure it is a LocalScript.
local shirt = "" -- shirt id
local pants = "" -- pants id
local Gui = script.Parent --change the location of Gui wherever it is
local Player = game.Players.LocalPlayer.Character --This is the player's character
Gui.MouseButton1Down:connect(function()
Player.ShirtId = shirt --I'm not sure if ShirtId is the correct property
Player.PantsId = pants
end)
local gui = script.Parent
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local Accessory = gui:WaitForChild("Accessory") --Or where ever your hat is stored
local package = game.Workspace.Package:GetChildren() --Or where ever your package is
gui.MouseButton1Down:connect(function()
for i,v in pairs(character:GetChildren()) do
if v:IsA("Shirt") then
v.ShirtTemplate = "DESIRED SHIRT ID" --For example: rbxassetid://1275157403
elseif v:IsA("Pants") then
v.PantsTemplate = "DESIRED PANTS ID" --For example: rbxassetid://1293205847
end
end)
--Do this to add a hat:
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid:AddAccessory(Accessory)
end
--Do this to add a package:
for i,v in pairs(package) do
v:Clone().Parent = character
end
end)
Put this in a LocalScript inside of your GUI button
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I think you should really learn scripting before trying to do something difficult.