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

How do we make a player Invisible in one script?

I Want to make a player invisible CODE: game.Workspace.Name of player.name of what you want.Tras = 0

2 comments

0

Do you mean change all their body transparency to 1 for every user?

0

Yes

2 answers

Here is a script that should do what you want, put it in a LocalScript in game.StarterGui or game.StarterPack, there is probably a easier way then adding the wait, but I'm not sure how to do it if there is.

wait(5) -- Stupid hats

local player = game.Players.LocalPlayer


for _,v in pairs(player.Character:GetChildren()) do
	if v.className == "Part" then
		v.Transparency = 1
	elseif v.className == "Hat" then
		v.Handle.Transparency = 1
	end
end

1 comment

2

Wouldn't it be better to use the 'IsA' method ( 'Instance:IsA(ChildClass)' )? :P

This is to be used in a Script and can be put in ServerScriptService or Workspace, whatever you prefer Well simply, we need to get the players, character, get all the characters parts, and set there transparency to 1, do do so we need to wait for a new player to enter, and get there character:

function onPlayerRespawned(newPlayer)
wait(1)

local Character = newPlayer.Character

And then we need to make sure that the characters torso is nil and make sure all his body parts are invisible like this:

if Character.Torso ~= nil then
Character.Torso.Transparency = 1
end
if Character.Head ~= nil then
Character.Head.Transparency = 1
end
if Character:findFirstChild("Right Leg")  ~= nil then
Character:findFirstChild("Right Leg").Transparency = 1
end
if Character:findFirstChild("Left Leg")  ~= nil then
Character:findFirstChild("Left Leg").Transparency = 1
end
if Character:findFirstChild("Right Arm")  ~= nil then
Character:findFirstChild("Right Arm").Transparency = 1
end
if Character:findFirstChild("Left Arm")  ~= nil then
Character:findFirstChild("Left Arm").Transparency = 1
end

Then we continue to remove our characters hats like so:

local x = Character:GetChildren()
for i=1, #x do
if x[i].className == "Hat" then
x[i]:Remove()

end
end

Then we continue to fallow up by checking fir the instance "sound" in the players head:

local y = Character.Head:GetChildren()
for x=1, #y do
if y[x].className == "Sound" then
x[i]:Remove()
end
end

Character.Head.face:Remove()
end

finally we close up the code:

function onPlayerEntered(newPlayer) 
	newPlayer.Changed:connect(function(property) 
		if (property == "Character") then 
			onPlayerRespawned(newPlayer) 
		end 
	end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered)

Final code:

function onPlayerRespawned(newPlayer)
wait(1)

local Character = newPlayer.Character

-------------------------------------------------------------------
if Character.Torso ~= nil then
Character.Torso.Transparency = 1
end
if Character.Head ~= nil then
Character.Head.Transparency = 1
end
if Character:findFirstChild("Right Leg")  ~= nil then
Character:findFirstChild("Right Leg").Transparency = 1
end
if Character:findFirstChild("Left Leg")  ~= nil then
Character:findFirstChild("Left Leg").Transparency = 1
end
if Character:findFirstChild("Right Arm")  ~= nil then
Character:findFirstChild("Right Arm").Transparency = 1
end
if Character:findFirstChild("Left Arm")  ~= nil then
Character:findFirstChild("Left Arm").Transparency = 1
end
-------------------------------------------------------------------
local x = Character:GetChildren()
for i=1, #x do
if x[i].className == "Hat" then
x[i]:Remove()

end
end

local y = Character.Head:GetChildren()
for x=1, #y do
if y[x].className == "Sound" then
x[i]:Remove()
end
end

Character.Head.face:Remove()
end


function onPlayerEntered(newPlayer) 
	newPlayer.Changed:connect(function(property) 
		if (property == "Character") then 
			onPlayerRespawned(newPlayer) 
		end 
	end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered)

HOPE THIS HELPED

1 comment

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