Is it possible to make a part invisblelize a player on touch then when not touch uninvisiblize the player.
script.Parent.Touched:Connect(function(plr) if plr.Parent:FindFirstChild("Humanoid") then for i, v in pairs(plr.Parent:GetChildren()) do if v:IsA("BasePart") then v.Transparency = 1 end if v:IsA("Accessory") then v.Handle.Transparency = 1 for index, value in pairs(v.Handle:GetDescendants()) do if value:IsA("ParticleEmitter") then value.Transparency = NumberSequence.new(1) end end end end plr.Parent.Head.face.Transparency = 1 end end) script.Parent.TouchEnded:Connect(function(plr) if plr.Parent:FindFirstChild("Humanoid") then for i, v in pairs(plr.Parent:GetChildren()) do if v:IsA("BasePart") then v.Transparency = 0 end if v:IsA("Accessory") then v.Handle.Transparency = 0 for index, value in pairs(v.Handle:GetDescendants()) do if value:IsA("ParticleEmitter") then value.Transparency = NumberSequence.new(0) end end end end plr.Parent.Head.face.Transparency = 0 plr.Parent.HumanoidRootPart.Transparency = 1 end end)
Insert this into a part.
This code is the same as @bebokhouja2's answer but with explanations and few improvisations.
script.Parent.Touched:Connect(function(hit) -- when the player touches the part local character = (game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) ~= nil) and hit.Parent -- checks if hit is the player's limb if character:FindFirstChildOfClass("Humanoid") then -- checks if the character has the "Humanoid" instance; detects if it's a real alive roblox character for i, v in pairs(character:GetDescendant()) do -- gets all of its descendants (the children of children of children of ... children of a part) if v:IsA("BasePart") then -- checks if it's a part/limb v.Transparency = 1 -- sets the limb invisible elseif v:IsA("Accessory") then -- if it's an accessory (e.g., Hat, Backpack, etc.) v.Handle.Transparency = 1 -- sets the accessory invisible for index, value in pairs(v.Handle:GetDescendants()) do -- gets its descendants if value:IsA("ParticleEmitter") then -- if it's a particle value.Transparency = NumberSequence.new(1) -- sets the particle to invisible end end end end character.Head.face.Transparency = 1 -- sets the face invisible end end) script.Parent.TouchEnded:Connect(function(hit) -- when the player leaves the part local character = (game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) ~= nil) and hit.Parent -- checks if hit is the player's limb if character:FindFirstChildOfClass("Humanoid") then -- checks if the character has the "Humanoid" instance; detects if it's a real alive roblox character for i, v in pairs(character:GetDescendants()) do -- gets all of its descendants (the children of children of children of ... children of a part) if v:IsA("BasePart") then -- checks if it's a part/limb v.Transparency = 0 -- sets the limb visible again elseif v:IsA("Accessory") then -- if it's an accessory (e.g., Hat, Backpack, etc.) v.Handle.Transparency = 0 -- sets the accessory visible again for index, value in pairs(v.Handle:GetDescendants()) do -- gets its descendants if value:IsA("ParticleEmitter") then -- if it's a particle value.Transparency = NumberSequence.new(0) -- sets the particle to visible again end end end end character.Head.face.Transparency = 0 -- sets the face invisible character.HumanoidRootPart.Transparency = 1 -- sets the rootPart to invisible otherwise the character would look glitchy and weird end end)