Making player character transparent locally?

  1. What do you want to achieve? Keep it simple and clear!
    I want to make the player’s character transparent locally including all their hats, clothes and other accessories (they’ll be invisible only for themselves, others will be able to see them)
  2. What is the issue? Include screenshots / videos if possible!
    I can’t seem to get it working.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried using this localscript in workspace (I wrote it myself):
local player = game.Players.LocalPlayer
for i, v in pairs(player.Character:GetChildren())
    v.Transparency = 1.0
end

Thanks!

2 Likes

Add this into the for loop:

If v:IsA(“Basepart”) then

1 Like

Utilize :GetDescendants() on the Character model so that everything on the first layer and every subsequent item inside of each of those Instances will be looked for.

In its current state, you’re only accessing everything on the first layer of the Character with :GetChildren()

for _,item in ipairs(player.Character:GetDescendants()) do
    if item:IsA("BasePart") then -- We are checking for this because BaseParts have a Transparency property -- this will prevent the code from erroring if it finds an object that is not a BasePart
        item.Transparency = 1
    end
end
1 Like

You will need to add: elseif v:IsA(Accessory) then v.Handle.Transparency = 1 end

Let me write the script real quick.

1 Like

Maybe this will work:

local player = game:GetService("Players").LocalPlayer
repeat wait() until player.Character
for _,v in pairs(player.Character:GetChildren) do
if v:IsA("BasePart") then
      v.Transparency = 1
end
end
1 Like

This will work:

--Variables--
local character = game:GetService("Players").LocalPlayer.Character or game:GetService("Players").LocalPlayer.CharacterAppearanceLoaded:Wait()

--Script--
for i, child in ipairs(character:GetChildren()) do
    if child:IsA("BasePart") and child ~= character:FindFirstChildWhichIsA("Humanoid").RootPart then
        child.Transparency = 1
    elseif child:IsA("Accessory") then
        child:WaitForChild("Handle").Transparency = 1
    end
end

Insert the LocalScript into game > StarterPlayer > StarterPlayerScripts:
Screenshot 07-03-2021 10.02.58

As you can see, this script is different from others. Why?

  1. We need to loop through every child when the character is fully loaded. If it isn’t fully loaded yet, it will not make every part transparent. player.CharacterAdded will fire when the player’s character model gets added into the game. player.CharacterAppearanceLoaded will fire when the player’s character model gets added into the game and every child is fully loaded. Therefore when we loop through every child, because we used player.CharacterAppearanceLoaded, everything is loaded correctly.

  2. We are also checking if the child is not the HumanoidRootPart, this is not necaessary for making the character transparent, though it is necessary for making the character visible again.

  3. A hat is not a BasePart, a hat is an Accessory. Though in the Accessory there is a part called “Handle” with a mesh in that part. Therefore if we’re checking a hat, the child is an Accessory, but the child of that Accessory is a part called “Handle”.

1 Like

Please mark someone’s post as a solution if it helped you.

1 Like

@iamajust I did it just like you told though its not working (no errors either)

@itsredstonepro Its working thanks! Now I’ll mix your script with the one @iamajust told (get basepart of hats etc to make them transparent too)

u forgot () after GetChildren btw

Thanks @iamajust and @itsredstonepro! Everything is working now!

oh lol i forgot to add the brackets

1 Like

I see, it should be:

--Variables--
local localplayer = game:GetService("Players").LocalPlayer

--Script--
localplayer.CharacterAppearanceLoaded:Connect(function(character)
    for i, child in ipairs(character:GetChildren()) do
        if child:IsA("BasePart") and child ~= character:FindFirstChildWhichIsA("Humanoid").RootPart then
            child.Transparency = 1
        elseif child:IsA("Accessory") then
            child:WaitForChild("Handle").Transparency = 1
        end
    end
end)
  1. Using wait() is a bad practice, it is much better to use RunService.Stepped:Wait()
  2. You didn’t call the GetChildren function, you only indexed it.
  3. Instead of repeat wait() until player.Character use player.Character or player.CharacterAdded:Wait()
  4. It’s generally better practice to use the LocalTransparencyModifier for these things.
1 Like

I know im using the other old way

repeat wait() until something

but it works

For anyone seeing this in the future, here’s the full script (it doesn’t make the “face” decal invisible but I don’t need that for now, to do that just check if the part’s name is head and run :FindFirstChild(“face”).Transparency = 1 on it):

local player = game:GetService("Players").LocalPlayer
repeat wait() until player.Character
for _,item in pairs(player.Character:GetChildren()) do
	if item:IsA("BasePart") then
		item.Transparency = 1
	elseif item:IsA("Accessory") then
		local handle = item:WaitForChild("Handle")
		handle.Transparency = 1
	end
end

Once again, thanks all! Especially @iamajust and @itsredstonepro!

2 Likes