This is one big thread with interesting replies. When that is said, here is your solution:
--Localscript:
local HatRemote = game:GetService("ReplicatedStorage"):WaitForChild("HatRemote")
local HatButton = script.Parent:WaitForChild("HatButton")
local Debounce = false
HatButton.Activated:Connect(function()
if Debounce then return end
Debounce = true
HatRemote:FireServer()
task.wait(0.5)
Debounce = false
end)
--Serverscript
local HatRemote = game.ReplicatedStorage.HatRemote
local Debounce = {}
HatRemote.OnServerEvent:Connect(function(Player)
if Debounce[Player.Name] then return end
Debounce[Player.Name] = true
local Character = Player.Character
if Character then
for _, Accessory in pairs(Character:GetChildren()) do
if Accessory:IsA("Accessory") and Accessory.AccessoryType == Enum.AccessoryType.Hat then
local Handle = Accessory:FindFirstChild("Handle")
if Handle then
if Handle.Transparency == 0 then
Handle.Transparency = 1
else
Handle.Transparency = 0
end
end
end
end
end
task.wait(0.5)
Debounce[Player.Name] = nil
end)
Setup:

somehow this ended up making the morphâs hat itself dissapear⌠meaning the player morphs as a silly guy under the mask, plus the function kinda works when you click it back, the helmet returns, and if clicked again, itâs the opposite, something like a loop thingâŚ
lemme just mention that my morph is âclick torso to become this personâ thing, so I think itâs because of that.
Scripting support is for programmers to communicate on issues in code, we donât help if there is no script to start withâŚ
1 Like
@GrizzlyDude27, try using my script, maybe, itâll work.
Look at these line in my script:
for _, Accessory in pairs(Character:GetChildren()) do
if Accessory:IsA("Accessory") and Accessory.AccessoryType == Enum.AccessoryType.Hat then
We go through all âChildren objectsâ in the morph/character. Then we check if that âchild objectâ(referred to as Accessory in this case, just know that all children are not accessories, we couldâve have called it anything, even Banana)
If that âchild objectâ is a âAccessoryâ and that "child object"s AccessoryType is equal to âHatâ then we turn it visible/invisible.
What you have to do, is some way specify which hat you want to dissapear. You can do this by adding another statement like this:
for _, Accessory in pairs(Character:GetChildren()) do
if Accessory:IsA("Accessory") and Accessory.AccessoryType == Enum.AccessoryType.Hat and Accessory.Name == "DarthVaderMask" then
well I do want it to reappear again and dissapear again per click on the accessory.