Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i find a player with their name?

Asked by 4 years ago
Edited by SerpentineKing 4 years ago
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.

0
is this on a LocalScript or a Script? TheBigBro122 427 — 4y
0
Local Script. preston1196 82 — 4y
0
and you are getting the Player that the LocalScript is on? TheBigBro122 427 — 4y
0
No preston1196 82 — 4y
0
rather than the second line you should try to use Players:WaitForChild(script.Parent.Parent.Value.Value) Wiggles1305 49 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by
kisty1 111
4 years ago

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

You should do

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

Instead

0
That just gets me a infinite yield. preston1196 82 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
The First one gives me a infinite yield and the second one just dosen't find it. preston1196 82 — 4y
0
did you at least make sure script.Parent.Parent.Value.Value has a value? TheBigBro122 427 — 4y

Answer this question