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

I am trying to reference the player. It's not working?

I am attempting to reference the player through game.Workspace[player.Name] . It's not working, why is this?

game.Players.PlayerAdded:Connect(function(player)
	print(game.Workspace[player.Name].Name) -- Printing name of player in workspace.
end)

My username is N43FGXL and I get the error: N43FGXL is not a valid member of Workspace When I check the explorer, the model of my character is in the workspace...

2 answers

✓ Accepted answer

You are confusing the player and the character. The character is the player's physical representation in-game. Just because the player has joined doesn't mean their physical appearance has loaded. To do what you described:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function (char)
		print(char.Name) -- char is equivalent to workspace[player.Name]
	end)
end)

You are over complicating things. It's actually quite simple!

game.Players.PlayerAdded:Connect(function(player)
    print(player.Name)
end)

1 comment

0

I'm trying to find the character in the workspace. I just had an example.

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