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

Help with Character Transparency?

Ok so I have this script that should be making characters transparent when they join the server, however it doesn't seem to be working. I also have no idea how to make the hats transparent along with it. Here's the script I have so far:

local Players = game:GetService("Players")
	

function onPlayerAdded(player)
	
game.Players.LocalPlayer.Character.Head.Transparency = 0.7
game.Players.LocalPlayer.Character.Torso.Transparency = 0.7
game.Players.LocalPlayer.Character["RightArm"].Transparency = 0.7
game.Players.LocalPlayer.Character["RightLeg"].Transparency = 0.7
game.Players.LocalPlayer.Character["LeftArm"].Transparency = 0.7
game.Players.LocalPlayer.Character["LeftLeg"].Transparency = 0.7

end

Players.PlayerAdded:connect(onPlayerAdded)




It used to just make my head and torso transparent, but now it doesn't even do that. It also tells me that "RightArm isn't a valid member of model", which I can't understand (unless it's supposed to be "Right Arm" instead of "RightArm". I just can't seem to figure out what i'm doing wrong. I'm still very basic with LUA so any help would be much appreciated.

~MrTurkeys

3 comments

0

Why not use for i, v in pairs(player.Character:GetChildren()) do if v:IsA("Part") then v.Transparency = 0.8 end

0

I'll try that now

0

And yeah it is "Right Arm"

2 answers

At first you start out good, like with the function and all, but then, for some reason, you make it game.Players.LocalPlayer instead of player. Oh, and you also forgot the spaces in the name of the limbs of the character.

Here, this should work:

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
player.Character.Head.Transparency = 0.7
player.Character.Torso.Transparency = 0.7
player.Character["Right Arm"].Transparency = 0.7
player.Character["Right Leg"].Transparency = 0.7
player.Character["Left Arm"].Transparency = 0.7
player.Character["Left Leg"].Transparency = 0.7
end)

Still doesn't work? Try this instead:

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
local Character=workspace:WaitForChild(player.Name)
Character.Head.Transparency = 0.7
Character.Torso.Transparency = 0.7
Character["Right Arm"].Transparency = 0.7
Character["Right Leg"].Transparency = 0.7
Character["Left Arm"].Transparency = 0.7
Character["Left Leg"].Transparency = 0.7
end)

3 comments

0

Isn't it Right arm, Left leg, ect. I might be wrong, I just thought it was lowercase on one or two of them.

0

no, it's Right Arm

0

Yep

Local Player only works in a Local Script

So, you should be using a Regular Script so you can make changes to the players on the Server. Even if FE is disabled, you should be using a Regular Script. I would suggest placing the script in ServerScriptService.

I would also suggest a pairs loop to get every part in the character, setting the transparency. We can use the IsA() function to check if the thing in the character is a part.

Next thing I would suggest is waiting for the Character to load with the CharacterAdded Event.

Example,

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		for i,v in pairs(char:GetChildren()) do
			if v:IsA("Part") then
				v.Transparency = 0.7
			end
		end
	end)
end)
I switched the functions to be anonymous.

Good Luck!

If I helped, please don't forget to accept my answer.

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