It works but there is two problems with it, one, it doesn't make hats and faces invisible too and two, when I toggle back to visible then it adds a grey block around the players torso.
local event = script.InvisFunction local Val = script.Parent.Hidden.Value event.OnServerEvent:Connect(function(player) if Val == false then Val = true local character = player.Character or workspace:FindFirstChild(player.Name) for k, v in pairs(character:GetChildren()) do if v:IsA('BasePart') then v.Transparency = 1 local decal = v:FindFirstChild('Decal') if decal then decal.Transparency = 1 end end end else Val = false local character = player.Character or workspace:FindFirstChild(player.Name) for y, t in pairs(character:GetChildren()) do if t:IsA('BasePart') then t.Transparency = 0 local decal = t:FindFirstChild('Decal') if decal then decal.Transparency = 0 end end end end end)
I suggest creating a folder inside of ServerStorage to store the player's Accessories.
Also that 'grey block' that is around the player's torso is the HumanoidRootPart. It's default transparency is set to 1, and when you're getting all the parts inside the Character you're also getting the HumanoidRootPart and setting the transparency to 0.
local ss = game:GetService("ServerStorage") local Event = game.ReplicatedStorage.InvisEvent local isInvis = false Event.OnServerEvent:Connect(function(Player) local Character = Player.Character if isInvis == true then isInvis = false for _, part in pairs(Character:GetDescendants()) do if part:IsA("BasePart") or part:IsA("MeshPart") then part.Transparency = 1 elseif part:IsA("Accessory") or part:IsA("FaceInstance") then if not ss.PlayerAccessories:FindFirstChild(Player.Name) then local PlayerAccessoryFolder = Instance.new("Folder") PlayerAccessoryFolder.Name = Player.Name PlayerAccessoryFolder.Parent = ss.PlayerAccessories end part.Parent = ss.PlayerAccessories[Player.Name] end end else isInvis = true if ss.PlayerAccessories:FindFirstChild(Player.Name) then for _, Accessory in pairs(ss.PlayerAccessories[Player.Name]:GetChildren()) do if not Accessory:IsA("FaceInstance") then Accessory.Parent = Character else Accessory.Parent = Character.Head end end for _, part in pairs(Character:GetDescendants()) do if part:IsA("BasePart") or part:IsA("MeshPart") then if part.Name ~= "HumanoidRootPart" then part.Transparency = 0 end end end end end end)
Hope this helps.
If you have any questions just post a comment to this answer and I'll try to answer them.