Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a certain hat in a certain players inventory GUI to equip and wear?

Asked by 3 years ago

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.

0
So , Pete , You only want a Certain or Special Player to where this hat? Tizzel40 243 — 3y
0
Yes PeteHyper -3 — 3y
0
You mean: Where meaning wear? PeteHyper -3 — 3y
0
Sooo can u help me? PeteHyper -3 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
0
Thank you very much :D PeteHyper -3 — 3y
0
Can u make it only for like a special or certain play that can wear the hat and also the certain player can equip / Unequip PeteHyper -3 — 3y
0
You are welcome NathanBlox_Studios 212 — 3y
Ad

Answer this question