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

[SOLVED] Infinite yield possible on 'Players:WaitForChild("Instance")'. What's wrong?

Asked by 5 years ago
Edited 5 years ago

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

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 User#20388 0 — 5y
0
probably for other players in the server and it's just a warning, in fact you don't need a waitforchild at all User#19524 175 — 5y
0
RedcommanderV2 it worked, thank you :D KrzysiekRoblox 50 — 5y

Answer this question