Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you get this script to continue to work after i die???

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)

4 comments

0

for loops needed

0

.9 is not a thing i think its 0.9

0

.9 is a thing... why wouldn't it be a thing???

0

loops would lag my game

1 answer

✓ Accepted answer

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)

5 comments

0

You forgot to use and v.Name ~= "HumanoidRootPart", but if humanoidrootpart is visible you can see a block in the character.

0

Can you explain why Zripples code is not working. Replace your code does not explain why it works.

0

I changed my character to r6... would this still work?

0

@LawlR Is there also a way to change this to remove your clothing? (also to work when you die)

0

Edited answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.