What script would I use to make my character go invisible when touching a brick and visible when not touching it? I've tried a lot.
local part = Workspace.Part part.Touched:connect(function(hitPart) local player = Game.Players:GetPlayerFromCharacter(hitPart.Parent) if player then for index, object in pairs(player.Character:GetChildren()) do if object:IsA("BasePart") then object.Transparency = 1 if object:FindFirstChild("face") then object.face.Transparency = 1 end elseif object:IsA("Hat") and object:FindFirstChild("Handle") then object.Handle.Transparency = 1 end end end end) part.TouchEnded:connect(function(hitPart) local player = Game.Players:GetPlayerFromCharacter(hitPart.Parent) if player then for index, object in pairs(player.Character:GetChildren()) do if object:IsA("BasePart") and object.Name ~= "HumanoidRootPart" then object.Transparency = 0 if object:FindFirstChild("face") then object.face.Transparency = 0 end elseif object:IsA("Hat") and object:FindFirstChild("Handle") then object.Handle.Transparency = 0 end end end end)
script.Parent.Touched:connect(function() for i, v in pairs (game.Players:GetPlayers()) do v.Character.Torso.Transparency = 1 v.Character.Head.Transparency = 1 v.Character["Left Leg"].Transparency = 1 v.Character["Left Arm"].Transparency = 1 v.Character["Right Arm"].Transparency = 1 v.Character["Right Leg"].Transparency = 1 end end) script.Parent.StoppedTouching:connect(function() for i, v in pairs ( game.Players:GetPlayers()) do v.Character.Torso.Transparency = 0 v.Character.Head.Transparency = 0 v.Character["Left Leg"].Transparency = 0 v.Character["Left Arm"].Transparency = 0 v.Character["Right Arm"].Transparency = 0 v.Character["Right Leg"].Transparency = 0 end end)
Put this script into the part you want