11:30:20.141 - Infinite yield possible on 'Players:WaitForChild("Instance")'

11:30:20.143 - Stack Begin

11:30:20.144 - Script 'Players.KrzysiekRoblox.PlayerGui.AdminGui.Frame.TextButton.LocalScript', Line 5

11:30:20.145 - Stack End

script.Parent.MouseButton1Down:Connect(function()
	local players = game:GetService("Players")
	local player = players:FindFirstChild(script.Parent.Parent.Player_Type.Text) -- Text is my nickname (KrzysiekRoblox)
	if player ~= nil then
		print(players:WaitForChild(player).Name)
	end 
end)

I can't find out, what's wrong in this script, if variable 'player' = KrzysiekRoblox, not 'Instance'... Thanks for help :D

3 comments

0

print(players:WaitForChild(player).Name) -- WaitForChild takes strings (names), NOT instances, to fix, make it print(players:WaitForChild(player.Name).Name) though I have no idea why you would want this as you already have the player object

0

probably for other players in the server and it's just a warning, in fact you don't need a waitforchild at all

0

RedcommanderV2 it worked, thank you :D