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

Hiding a Players name when they join?

Alright, so I was trying to make a script to hide the players name when they joined:

game.Players.PlayerAdded(player):connect(function()
	player.Character.WaitForChild("Humanoid")
		player.Character.Head.Transparency = 1
end)

But it gives me this error:

16:49:14.081 - Workspace.Script:1: attempt to call field 'PlayerAdded' (a userdata value) 16:49:14.086 - Script 'Workspace.Script', Line 1 16:49:14.086 - stack end

I don't know what I'm doing wrong.

5 answers

✓ Accepted answer

Firstly, you have to take out the (players) part, because that is supposed ton go betwixt(or between. I prefer betwixt) the parenthesis after function, like this:

game.Players.PlayerAdded:connect(function(player)

Also, there's another problem in 'player.Character.WaitForChild("Humanoid")' You need a Colon betwixt(or between) Character and WaitForChild, because it is a method.

For example:

player.Character:WaitForChild("Humanoid")

Here's the script fixed, although I doubt it'd work anyway:

game.Players.PlayerAdded:connect(function(player)
player.Character:WaitForChild("Humanoid")
player.Character.Head.Transparency = 1
end)

You should use something more like this though, as it is more effective in doing things like this. Don't use this of you don't want their names hidden when they spawn though, but I didn't know invisible heads made names invisible in the first place.

Game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Head = Character.Head
if Head then
Head.Transparency = 0
end
end)
end)

Well, I hope this helped.

  • Kratos232

Your problem is you're trying to use PlayerAdded as a method.

To fix your problem, just simply take out the (player) part after PlayerAdded and put player inside of the parenthesis after function.

You also need to use a : for the WaitForChild method.

game.Players.PlayerAdded:connect(function(player)
    if player.Character:WaitForChild("Humanoid") then
        player.Character.Head.Transparency = 1
	end
end)

You are forgetting Workspace because that is where you are getting your Player from. Try it.

game.Players.PlayerAdded:connect(function(plr)
	if plr.Character:WaitForChild("Humanoid") then
		player.Character.Head.Transparency = 1
	end
end)

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