Character Transparency script not working

Hello everyone, I’m having a really annoying issue with my code to turn a character invisible for a jumpscare, I hope someone can help :confused:

  1. What do you want to achieve?

I want the character to turn invisible on the client for a jumpscare in my game, so the character isn’t in the way

  1. What is the issue?

The code, even though it looks like it works, it doesn’t, it doesn’t do anything at all.
And I don’t know what I’m doing wrong

  1. What solutions have you tried so far?

I’ve tried getting the code straight from the roblox website, rewriting it, and even going back to an autosave from April.

I really hope someone can help me, I’m so frustrated :tired_face:!

	for i,v in pairs(character:GetChildren()) do
		if v:IsA("Hat") or v:IsA("Accessory") and v:WaitForChild("Handle") then
			v.Handle.Transparency = 1
		end
		if v:IsA("BasePart") then
			v.Transparency = 1
		end
		if v:FindFirstChild("face") then
			v.face.Transparency = 1
		end
	end

The code seems to work fine for me, it may be possible that this part of the code isn’t triggered. You could print something to make sure that code gets executed.

OMG I didn’t think of that! I’ll try it, i’ll message you back in a minute :smiley:

I tried it, by putting this code after each transparency line, and this is what i got
But nothing happened still :frowning:

So the code is running, but something isn’t working changing it’s transparency

try this.

local plr = game.Players:WaitForChild("") -- player name

if plr.Character ~= nil then
for _,v in pairs(plr.Character:GetDescendants()) do
	if v:IsA("UnionOperation") or v:IsA("Part") or v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("TrussPart") or v:IsA("Decal") then
		v.Transparency = 1
	end
end
end

Alright, i’ll try this :smiley:

1 Like

Nope, didn’t work, I’m so confused and frustrated!

Also, i forgot to mention that it’s a local script, but that shouldn’t affect it, it was working about a day ago

well I test it with R6 character and it works fine, do you put your name in the local?
if you did what error it gives?

If you specifically want it to occur on the client only you need to fire a remote event
so here for example you touched a part, so now you fire the remote event by getting the player from the character in that way what will happen is only for you the character is going to be invisible but not for the server.
And yes it works fine as I have tested it already.
If you are still confused here are scripts for better understanding



me on server

me on client

There aren’t any errors, which is the weird part and yeah, the local player and character are both referenced

the reference for the character is

local character = player.Character or player.CharacterAdded:Wait()

Yeah, there is a remote event that’s fired when you touch the monster hitbox ingame, and i added print functions to it and they’re showing up in the output

so you prefer that one, try edit the code a bit, if it works for me it must be works for you right… unless you don’t know how to use it heh, good luck.

Alright, thanks for trying to help me :slightly_smiling_face:

1 Like

Well, I’d say use your current script (the first one) with character:GetDescendants, not character:GetChildren. Hope it helped.

Ok, i’ll try it, i’ll get back to you in like 2 mins

Nope, still didn’t work! I’m so frustrated, but thanks for trying to help dude, I’m grateful.

If you respond again, i’ll probably be 30 mins, have to clear my mind for a bit

1 Like

UPDATE: After like 3 hours of frustrated testing, I tried putting the invisibility script into another screenGUI (it’s for a piggy style game) I don’t know what in the world was wrong with that other GUI, but it’s solved now, thank you all so much for all your help :heart: