local character = game.Workspace.Player1
local player = game.Players:GetPlayerFromCharacter(character)
if player then
print("Player is " .. player.Name)
else
print("Player doesn't exist!")
end
✓ ANSWER ACCEPTED
I keep getting this error - Player1 is not a valid member of Workspace, Can anyone help me?
1 answer
✓ Accepted answer
One way to fix this would be to use :WaitForChild() now I'm not sure if this is the best method, but it works :)
local character = game.Workspace:WaitForChild("Player1")
local player = game.Players:GetPlayerFromCharacter(character)
if player then
print("Player is " .. player.Name)
else
print("Player doesn't exist!")
end
Elaborate The error "Player1 is not a valid member of Workspace" is displaced because the script ran before the character loaded, so the player wasn't part of Workspace.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Thank you so much also how do you change my text into code format?
When you post/edit the question there is a Lua code logo on top of the textbox where you write the question, click on it and put your code in the middle.
Ok thank you