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

Is this the best way to turn a player invisible or is there an easier way?

Here is my script:

					elseif msg:lower():sub(1, 9) == "invisible" then
							
						for i,v in pairs(character:GetChildren()) do
								
							if v:IsA("BasePart")or v:IsA("Decal") then
								
								v.Transparency = 1
		
								local face = v:FindFirstChild("face")
								
								if face then
							
									face.Transparency = 1
									
								end
							
							elseif v:IsA("Accessory") or v:IsA("Accoutrement") then
								
								local handle = v:FindFirstChild("Handle")
								
								if handle then
									
									handle.Transparency = 1
									
								end	
								
							end	
														
						end
						
					end

I just think there would be an easier way. I tried just checking if v was a basepart but then the face and hair were visible. I hope you guys can help. Thanks!

1 comment

0

I would recommend looking for meshparts too. r15 uses meshparts

1 answer

This way is perfectly fine.

:)

Could shorten the elseif statement to:

local handle = v:FindFirstChild("Handle")

if handle then
	handle.Transparency = 1
end

And this will automatically check for anything that has a handle and make it transparent.

9 comments

0

Will it work in every situation presented to it?

0

like with various attatchments and accessories?

0

As long as you're not adding your own custom items that aren't parts or accessories to the player, then yes

0

custom items?

0

also is there any way that I could use fewer or or if statements

0

This looks short enough to me.

0

Why did you post this as an answer..

0

Well is it not an answer to his question? :)

0

@Phlegethon5778, I updated my answer to shorten the elseif.

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