Make a character invisible on spawn

Hi all.
A friend helped me design a script that makes a players character invisible to everyone, but I can’t get it to work. The character should be invisible, including decals and accessories.

while wait() do
	for i,v in pairs(game.Players:GetPlayers()) do


				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   
			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

There are a lot of scripts out there that can get this to work.

Tried all of those and I cant get them to work.

function playerAddedEvent(player)
   --Must be done on spawn so that the body is invisible first
   player.CharacterAdded:Connect(function(character)
      task.wait()
      for _, part in character:GetDescendants() do
         if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
         
         part.Transparency = 1
      end
   end)
   --Then must be done again when appearance such as accessory loads in
   player.CharacterAppearanceLoaded:Connect(function(character)
      for _, part in character:GetDescendants() do
         if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
         
         part.Transparency = 1
      end
   end)
end

game.Players.PlayerAdded:Connect(function(player)
   playerAddedEvent(player)
end)

for _, player in game.Players:GetPlayers() do
   playerAddedEvent(player)
end

Thanks! Am I correct that I put it in StarterCharacterScripts or do I put it in ServerPlayerScripts?

It depends on if you want this to work on clientside or serverside

ServerScriptService for server

StarterPlayerScript for client

--Then must be done again when appearance such as accessory loads in
   player.CharacterAppearanceLoaded:Connect(function(character)```

The 'player' is underlined in red, does this mean I have to declare what player is?

I forgot, add end bracket ) after the 2 connected functions

Supposed to be

example.Event:Connect(function(example)

end) --This ) here is missing!
function playerAddedEvent(player)
   --Must be done on spawn so that the body is invisible first
   player.CharacterAdded:Connect(function(character)
end)
      task.wait()
		for _, part in character:GetDescendants() do
         if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
         
         part.Transparency = 1
      end
	end
	
   --Then must be done again when appearance such as accessory loads in
	player.CharacterAppearanceLoaded:Connect(function(character)
		end)
      for _, part in character:GetDescendants() do
         if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
         
         part.Transparency = 1
      end
   end
end

game.Players.PlayerAdded:Connect(function(player)
   playerAddedEvent(player)
end)

for _, player in game.Players:GetPlayers() do
   playerAddedEvent(player)
end

like this?

Try this code on a script in serverscriptservice:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local plrcharacter = game.Workspace:WaitForChild(character.Name) or player.Character or player.CharacterAdded:Wait()
		local Head = plrcharacter:WaitForChild("Head")
		for i,v in pairs(plrcharacter:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Part") then
				if v.Name ~= "HumanoidRootPart" then
					v.Transparency = 1
				end
				for i,v in pairs(Head:GetDescendants()) do
				if v:isA("Decal") then
				v:Destroy()
				end
				print(player.Name.."'s character has turned invisible")
				end
			end
		end
	end)
end)
1 Like

Doesn’t work. The character stays the same

1 Like

hold on. i know the problem now lol

Edited the reply post with fix

The problem has been fixed but I noticed that some accessories still had their meshes showing, let me fix that real quick…

All problems with the script has now been fixed.