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.
01 | local part = Workspace.Part |
02 | part.Touched:connect( function (hitPart) |
03 | local player = Game.Players:GetPlayerFromCharacter(hitPart.Parent) |
04 | if player then |
05 | for index, object in pairs (player.Character:GetChildren()) do |
06 | if object:IsA( "BasePart" ) then |
07 | object.Transparency = 1 |
08 | if object:FindFirstChild( "face" ) then |
09 | object.face.Transparency = 1 |
10 | end |
11 | elseif object:IsA( "Hat" ) and object:FindFirstChild( "Handle" ) then |
12 | object.Handle.Transparency = 1 |
13 | end |
14 | end |
15 | end |
01 | script.Parent.Touched:connect( function () |
02 | for i, v in pairs (game.Players:GetPlayers()) do |
03 | v.Character.Torso.Transparency = 1 |
04 | v.Character.Head.Transparency = 1 |
05 | v.Character [ "Left Leg" ] .Transparency = 1 |
06 | v.Character [ "Left Arm" ] .Transparency = 1 |
07 | v.Character [ "Right Arm" ] .Transparency = 1 |
08 | v.Character [ "Right Leg" ] .Transparency = 1 |
09 | end |
10 | end ) |
11 | script.Parent.StoppedTouching:connect( function () |
12 | for i, v in pairs ( game.Players:GetPlayers()) do |
13 | v.Character.Torso.Transparency = 0 |
14 | v.Character.Head.Transparency = 0 |
15 | v.Character [ "Left Leg" ] .Transparency = 0 |
16 | v.Character [ "Left Arm" ] .Transparency = 0 |
17 | v.Character [ "Right Arm" ] .Transparency = 0 |
18 | v.Character [ "Right Leg" ] .Transparency = 0 |
19 | end |
20 | end ) |
Put this script into the part you want