0

How do i find a player with their name?

Edited by SerpentineKing 11 months 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 359 — 11mo
0
Local Script. preston1196 22 — 11mo
0
and you are getting the Player that the LocalScript is on? TheBigBro122 359 — 11mo
0
No preston1196 22 — 11mo
0
rather than the second line you should try to use Players:WaitForChild(script.Parent.Parent.Value.Value) Wiggles1305 49 — 11mo

0

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.

0
kisty1 111
11 months ago

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

You should do

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


0
That just gets me a infinite yield. preston1196 22 — 11mo
0
Edited 11 months 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 22 — 11mo
0
did you at least make sure script.Parent.Parent.Value.Value has a value? TheBigBro122 359 — 11mo