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

Can't find player via TextBox?

local label = script.Parent.Parent.Test
local inputLabel = script.Parent

local players = game.Players:GetChildren()


while true do
	wait(5)
	if table.find(players, inputLabel.Text) then
			label.Text = 'Success!'
		else
			label.Text = 'Waiting...'
			wait(1)
			label.Text = 'Failure..!'
	end
end

I have a TextBox where you can input the name, however, I always get the Failure option. How can I successfully check for the name of a player in the TextBox?

1 answer

This is because the content of the array players is actually of type Player Objects, and you're trying to compare a string. Instead, you can reference the Player Object in the Players container via the Name and String:

local Players = game:GetService("Players")

local Label = script:FindFirstAncestor("Test")
local InputLabel = script.Parent

while wait(5) do
	if (table.find(Players:GetPlayers(), Players[InputLabel.Text]) then
		Label.Text = 'Success!'
	else
		Label.Text = 'Waiting...'
		wait(1)
		Label.Text = 'Failure..!'
	end
end

4 comments

0

Thanks, I’ll try it out when I get back on my PC

0

No problem!

0

" is not a valid member of Players", Late response, but the this is the new error which erupts from the new table.find

0

Blankspace is not a valid member? Are you sure you typed the username in?

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