This is the script:
tool = script.Parent player = game.Players.LocalPlayer toggle = false folder = nil function CreateFolder() if player:FindFirstChildClass("Folder") == nil then folder = Instance.new("Folder", player) folder.Name = "Accessories" end end local function MoveAccessories(str) if str == "Player" then accessories = folder:GetChildren() elseif str == "Folder" then accessories = player.Character:GetChildren() end end CreateFolder() function Toggle() if toggle == false then toggle = true else toggle =false end end function SetVisibility() local function SetPartVisible(trans) local human = player.Character:GetChildren() for i, part in ipairs(human) do if part:IsA("Part")and part.Name == "HumanoidRoot" then if str == "Player" then item.Parent = player.Character elseif str == "Folder" then item.Parent = folder end end end end local function MoveFace(str) if str == "Player" then folder.face.Parent = player.Character.Head. elseif str == "Folder" then player.Character.head.face.Parent = folder end if toggle == true then SetPartVisible(1) MoveAccessories("Folder") MoveFace("Folder") else SetPartVisible(0) MoveAccessories ("Player") MoveFace("Player") end end tool.Activated:connect(function() toggle() SetVisibility() end)
I went through your code, I there is a lot messed up, you forget ends, you don't capitalize somethings and there are just some functions that seem unnecessary. I recommend re-scripting it entirely. Heres a checklist:
(you don't need to store the accessories, you can make them invisible also by finding their handle.)
Here's and example I just cooked up
tool = script.Parent player = game.Players.LocalPlayer toggle = 0 function Toggle() if toggle == 1 then toggle = 0 elseif toggle == 0 then toggle = 1 end end function invisibility() for _, item in pairs(player.Character:GetChildren()) do if item:IsA("Part") and item.Name ~= "HumanoidRootPart" then if item.Name == "Head" then item.face.Transparency = toggle item.Transparency = toggle else item.Transparency = toggle end elseif item:IsA("MeshPart") then item.Transparency = toggle elseif item:IsA("Accessory") then item.Handle.Transparency = toggle end end end tool.Activated:Connect(function() Toggle() invisibility() end)