Hi my name PeteHyper and I have been wondering how to make a hat in a inventory GUI for a certain player to equip a certain custom hat when ever they join it’s still there? Help. I’m not a great Scripter I’m just a very beginner Scripter.
Put a localscript in the button, put the hat in replicated storage and type the following.
!!Be sure to remove all hats on the player!!
local hat = game.ReplicatedStorage.Hat -- Change to hat name local button = script.Parent button.MouseButton1Click:Connect(function() local char = game.Players.LocalPlayer.Character if char ~= nil then local clone = hat:Clone() clone.Parent = char clone.Name = "Hat" -- Change to hat name end end)
EDIT : if you want to make a equip and unequip, create a boolean value in the button and set it to false, then type the following
local hat = game.ReplicatedStorage.Hat -- Change to hat name local button = script.Parent local boolean = script.Parent.BooleanValue --Change to the name of the value button.MouseButton1Click:Connect(function() if boolean == false then local char = game.Players.LocalPlayer.Character if char ~= nil then local clone = hat:Clone() clone.Parent = char print("Equipped") end button.Text = "Unequip" else local char = game.Players.LocalPlayer.Character if char ~= nil then local clonedhat = char:WaitForChild("Hat") --Rename to hat name clonedhat:Destroy() print("Unequipped") end button.Text = "Equip" end end)