Would an OnTouch help? I don't know how to add that to this. Please Help.
01 | game.Players.PlayerAdded:connect( function (player) |
02 | local Character = player.Character or player.CharacterAdded:wait() |
03 | Character.Head.Transparency = 1 |
04 | Character.UpperTorso.Transparency = . 9 |
05 | Character.LowerTorso.Transparency = . 9 |
06 | Character.LeftUpperArm.Transparency = . 9 |
07 | Character.LeftLowerArm.Transparency = . 9 |
08 | Character.LeftHand.Transparency = . 9 |
09 | Character.RightUpperArm.Transparency = . 9 |
10 | Character.RightLowerArm.Transparency = . 9 |
11 | Character.RightHand.Transparency = . 9 |
12 | Character.LeftUpperLeg.Transparency = . 9 |
13 | Character.LeftLowerLeg.Transparency = . 9 |
14 | Character.LeftFoot.Transparency = . 9 |
15 | Character.RightUpperLeg.Transparency = . 9 |
16 | Character.RightLowerLeg.Transparency = . 9 |
17 | Character.RightFoot.Transparency = . 9 |
18 | end ) |
Replace your code with this code:
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (player) -- Same as your first line. |
02 | player.CharacterAdded:Connect( function (character) -- The following code will happen every time you spawn. |
03 | -- Your transparency code. Instead of writing out every body part, do this instead: |
04 | for i,v in pairs (character:GetChildren()) do |
05 | if v:IsA( "BasePart" ) and v.Name ~ = "Head" then |
06 | v.Transparency = 0.9 |
07 | end |
08 | end |
09 | character.Head.Transparency = 1 |
10 | end ) |
11 | end ) |
Haven't tested, there may be typos.
To answer comments:
@yHasteeD HumanoidRootPart counts as BasePart, and it is invisible by default.
@kingdom5 I said 'instead of writing out every body part' which suggests that this is a way to go through all of the body parts without actually writing them all out. I didn't comment on the rest of it because it basic English. If v is a base part, there's no need to explain that.
@Zripple Yes, it would still work if you used R6 characters. To remove your clothing, you would need to check if 'v' is a clothing instance and if it is, destroy it. There are 3 clothing instances: Shirt, Pants, and ShirtGraphic (T-shirts).
1 | if v:isA( "Shirt" ) or v:IsA( "Pants" ) or v:IsA( "ShirtGraphic" ) then |
2 | v:Destroy() |
3 | end |
You would want to add that code into the for loop with an elseif.
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (player) |
02 | player.CharacterAdded:Connect( function (character) |
03 | for i,v in pairs (character:GetChildren()) do |
04 | if v:IsA( "BasePart" ) and v.Name ~ = "Head" then |
05 | v.Transparency = 0.9 |
06 | elseif v:isA( "Shirt" ) or v:IsA( "Pants" ) or v:IsA( "ShirtGraphic" ) then -- Removing clothes. |
07 | v:Destroy() |
08 | end |
09 | end |
10 | character.Head.Transparency = 1 |
11 | end ) |
12 | end ) |