How to make player invisible?

Hello! How can I code a player invisible in roblox? I tried with the player parts but it didn’t work for me, some know or could give me some tip please

13 Likes

Just for loop on their character and if the iteration iterates a BasePart, set the transparency to 1.

2 Likes

if u have any questions PLEASE ASK

for i,v in pairs(Character:GetDescendants()) do -- loop through everything in the character
if v:IsA("BasePart") or v:IsA("Decal") then -- if it is a part
v.Transparency = 1 -- make it invisible
end
end
	end
26 Likes

yeah, same thing as what @ItzMeZeus_IGotHacked was saying and I have made a script to go with that which also has making to character and accessories visible as well as invisible:

local char = script.Parent

wait(8)

for _,part in pairs(char:GetChildren()) do
if part.ClassName == “MeshPart” or part.ClassName == “Part” then
part.Transparency = 1
end
end

for _,part in pairs(char:GetChildren()) do
if part.ClassName == “Accessory” then
for _,AccessoryPart in pairs(part:GetChildren()) do
AccessoryPart.Transparency = 1
end
end
end
for _,part in pairs(char.Head:GetChildren()) do
if part.ClassName == “Decal” then
part.Transparency = 1
end
end

– this part is for making the character visable again

wait(5)

for _,part in pairs(char:GetChildren()) do
if part.ClassName == “MeshPart” or part.ClassName == “Part” then
if part.Name ~= “HumanoidRootPart” then
part.Transparency = 0
end
end
end

for _,part in pairs(char:GetChildren()) do
if part.ClassName == “Accessory” then
for _,AccessoryPart in pairs(part:GetChildren()) do
AccessoryPart.Transparency = 0
end
end
end
for _,part in pairs(char.Head:GetChildren()) do
if part.ClassName == “Decal” then
part.Transparency = 0
end
end

8 Likes

In your case, using

GetDescendants()

should be better like in my code

3 Likes

thanks for the advice @hestolemyrice

3 Likes

Thank you guys so much! And is there a way to make only members of an invisible team? For example, I’m from the green team and can only see my team members, and the red team can only see the red team, is this possible? :o

2 Likes

Get a local script in StarterCharacterScript and write this

while wait() do
	for i,v in pairs(game.Players:GetPlayers()) do
		
			
		if v.TeamColor == game.Players:FindFirstChild(script.Parent.Name).TeamColor then
			if v.Name == script.Parent.Name then
				else
			for i,v in pairs(workspace:FindFirstChild(v.Name):GetDescendants()) do 

				if v:IsA("BasePart") or v:IsA("Decal") then 
						if v.Name == "HumanoidRootPart" then
							else
						
							v.Transparency = 0
							end
				end
			end
		end
       else    
	for i,v in pairs(workspace:FindFirstChild(v.Name):GetDescendants()) do 
		if v:IsA("BasePart") or v:IsA("Decal") then 
			v.Transparency = 1 
		end
	end




end
end
end

it worked for me

4 Likes

You can just check for class “BasePart” instead of several part types.

If you have a risk of non-limb parts, use the function GetLimb from Humanoid and if there is a result, then you know the part is from the character.

3 Likes

Wow cool!! Thanks you a lot! :smile:

I need the Character te become visible again after 8 Seconds, ive tried the following:

local function onInvisibleEventFired(Player, Character)
for i,v in pairs(Player.Character:GetDescendants()) do – loop through everything in the character
if v:IsA(“BasePart”) or v:IsA(“Decal”) then – if it is a part
v.Transparency = 1 – make it invisible
wait(8)
v.Transparency = 0
end
end
end

InvisibleEvent.OnServerEvent:Connect(onInvisibleEventFired)

The wait(8) is inside the loop so a part’s transparency will become 1, wait, transparency becomes 0,then go to next Part and so on.(if im not wrong)
So therefore,
ur script

local function onInvisibleEventFired(Player, Character)
for i,v in pairs(Player.Character:GetDescendants()) do -- loop through everything in the character
if v:IsA(“BasePart”) or v:IsA(“Decal”) then -- if it is a part
v.Transparency = 1-- make it invisible
wait(8)
v.Transparency = 0
end
end
end

InvisibleEvent.OnServerEvent:Connect(onInvisibleEventFired)

should be

local function onInvisibleEventFired(Player, Character)
for i,v in pairs(Player.Character:GetDescendants()) do -- loop through everything in the character
if v:IsA(“BasePart”) or v:IsA(“Decal”) then -- if it is a part
v.Transparency = 1 -- make it invisible
end
end -- after all parts are transparent
wait(8) 
for i,v in pairs(Player.Character:GetDescendants()) do -- make it visible as it has already been 8 sec
if v:IsA(“BasePart”) or v:IsA(“Decal”) then -- if it is a part
if v.Name == "HumanoidRootPart" then
else
v.Transparency = 0 -- dont make it invisible
end
end
end
end

InvisibleEvent.OnServerEvent:Connect(onInvisibleEventFired)
1 Like

where do i put this?
is it a script or local btw