Okay this script has had problems before, with not working, but I fixed main issues, by removes the parts where it makes the face decal transparent and same with root parts.
That may have made the script work great but however I don't like seeing the face of someone when then are suppose to be invisible, and when I turn then visible again, I don't want to see their root part.
The other thing is the only major glitch I have encountered. If a player dies, this script will not connect this player again until you have died and reset the script. So if a player resets and the script of the player says that player should be invisible, they wont be. Could there be a way of using a function to detect when a player dies, rather than using a while true do.
[Okay I found a way to counter the glitch above, I have a small while true do script in the player that waits for the player's health to equal 0. When this happens it Fires a ServerEvent when ALSO fixes the players camera (Just in case they are viewing a cutscene) and it clones a script into the player's playergui that does what the script does below then removes itself.]
Here is the script:
local player = game.Players.LocalPlayer
local char = player.Character
wait(3)
if player.PlayerService.PlayerTeam.Value == BrickColor.new("White") then
wait(1)
for i, v in pairs(game.Players:GetChildren()) do
if v.Name == player.Name then
wait()
elseif v:IsA'Player' then
for p, t in pairs (v.Character:GetChildren()) do
if t.Name == "HumanoidRootPart" then
wait()
elseif t.Name == "Head" then
t.Transparency = 1
t.face.Transparency = 1
elseif t:IsA'Part' then
t.Transparency = 1
elseif t:IsA'Hat' then
t.Handle.Transparency = 1
end
end
end
end
end
game.Players.PlayerAdded:connect(function (newPlayer)
wait(1)
if player.PlayerService.PlayerTeam.Value == BrickColor.new("White") then
for i, v in pairs(game.Players:GetChildren()) do
if v.Name == player.Name then
wait()
elseif v:IsA'Player' then
for p, t in pairs (v.Character:GetChildren()) do
if t.Name == "HumanoidRootPart" then
wait()
elseif t.Name == "Head" then
t.Transparency = 1
t.face.Transparency = 1
elseif t:IsA'Part' then
t.Transparency = 1
elseif t:IsA'Hat' then
t.Handle.Transparency = 1
end
end
end
end
end
end)
player.PlayerService.PlayerTeam.changed:connect(function(val)
wait(1)
if val == BrickColor.new("White") then
for i, v in pairs(game.Players:GetChildren()) do
if v.Name == player.Name then
wait()
elseif v:IsA'Player' then
for p, t in pairs (v.Character:GetChildren()) do
if t.Name == "HumanoidRootPart" then
wait()
elseif t.Name == "Head" then
t.Transparency = 1
t.face.Transparency = 1
elseif t:IsA'Part' then
t.Transparency = 1
elseif t:IsA'Hat' then
t.Handle.Transparency = 1
end
end
end
end
end
if val == BrickColor.new("Bright red") then
for i, v in pairs(game.Players:GetChildren()) do
if v.Name == player.Name then
wait()
elseif v:IsA'Player' then
for p, t in pairs (v.Character:GetChildren()) do
if t.Name == "HumanoidRootPart" then
wait()
elseif t.Name == "Head" then
t.Transparency = 0.9
t.face.Transparency = 1
elseif t:IsA'Part' then
t.Transparency = 0.9
elseif t:IsA'Hat' then
t.Handle.Transparency = 0.9
end
end
end
end
end
if val == BrickColor.new("Medium stone grey") then
for i, v in pairs(game.Players:GetChildren()) do
if v.Name == player.Name then
wait()
elseif v:IsA'Player' then
for p, t in pairs (v.Character:GetChildren()) do
if t.Name == "HumanoidRootPart" then
wait()
elseif t.Name == "Head" then
t.Transparency = 0
t.face.Transparency = 0
elseif t:IsA'Part' then
t.Transparency = 0
elseif t:IsA'Hat' then
t.Handle.Transparency = 0
end
end
end
end
end
end)

1 comment
use Humanoid.Died to do something when the humanoid dies.