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

How do i find a player with their name?

local Players = game:GetService("Players")
local player = game:WaitForChild(Players[script.Parent.Parent.Value.Value]) 

The Value is a string value containing the player's name. but the error i'm getting says that preston1196 is not a valid member of Players. So it can't find my username in the Players.

5 comments

0

is this on a LocalScript or a Script?

0

Local Script.

0

and you are getting the Player that the LocalScript is on?

0

No

0

rather than the second line you should try to use Players:WaitForChild(script.Parent.Parent.Value.Value)

3 answers

✓ Accepted answer

I did a bit of messing around and found out a space got into the string and thats what caused it not to find it.

You're doing game:WaitForChild(...)

You should do

local player = Players:WaitForChild(script.Parent.Parent.Value.Value)

Instead

1 comment

0

That just gets me a infinite yield.

I assume that "Value" is a StringValue

The problem is Value is a Property, so use :WaitForChild()

Try either one

local player = Players:WaitForChild(script.Parent.Parent:WaitForChild("Value").Value)

2 comments

0

The First one gives me a infinite yield and the second one just dosen't find it.

0

did you at least make sure script.Parent.Parent.Value.Value has a value?

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