Would an OnTouch help? I don't know how to add that to this. Please Help.
game.Players.PlayerAdded:connect(function(player) local Character = player.Character or player.CharacterAdded:wait() Character.Head.Transparency = 1 Character.UpperTorso.Transparency = .9 Character.LowerTorso.Transparency = .9 Character.LeftUpperArm.Transparency = .9 Character.LeftLowerArm.Transparency = .9 Character.LeftHand.Transparency = .9 Character.RightUpperArm.Transparency = .9 Character.RightLowerArm.Transparency = .9 Character.RightHand.Transparency = .9 Character.LeftUpperLeg.Transparency = .9 Character.LeftLowerLeg.Transparency = .9 Character.LeftFoot.Transparency = .9 Character.RightUpperLeg.Transparency = .9 Character.RightLowerLeg.Transparency = .9 Character.RightFoot.Transparency = .9 end)
Replace your code with this code:
game:GetService("Players").PlayerAdded:Connect(function(player) -- Same as your first line. player.CharacterAdded:Connect(function(character) -- The following code will happen every time you spawn. -- Your transparency code. Instead of writing out every body part, do this instead: for i,v in pairs(character:GetChildren()) do if v:IsA("BasePart") and v.Name ~= "Head" then v.Transparency = 0.9 end end character.Head.Transparency = 1 end) 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).
if v:isA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") then v:Destroy() end
You would want to add that code into the for loop with an elseif.
game:GetService("Players").PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) for i,v in pairs(character:GetChildren()) do if v:IsA("BasePart") and v.Name ~= "Head" then v.Transparency = 0.9 elseif v:isA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") then -- Removing clothes. v:Destroy() end end character.Head.Transparency = 1 end) end)