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

Why does player become nil, when I try to find it?

At output it's prints nil, instead of my name ingame. Here is the code:

local playerToFind = hit.Parent.Name -- Hit is the way I find out what touched the brick.
local playerService = game:GetService("Players")
local player  = playerService:FindFirstChild(playerToFind)
print(player)

I really have no idea why, I hope someone can help me. - Toby

2 comments

0

It works sometime.

0

Nvm works now....

1 answer

The problem is that at line 4, you didn't convert the name of the player. You can just do:

print(player.Name)

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