How do i get rid of warning?

hello, Is there a way to stop warning from happening?

local function RenderStep()
	if (workspace.RadioGamepassPrompt.Position - HumanoidRootPart.Position).magnitude < 10 then
		ContextActionService:BindAction("PromptGamePassRadio",GamepassPormptRaidio,false,Enum.KeyCode.E)
	else
		ContextActionService:UnbindAction("PromptGamePassRadio")
	end
	if (workspace.LimterShopNpc.Raccoon.Head.Position - HumanoidRootPart.Position).magnitude < 7 then
		ContextActionService:BindAction("RadioRaccon",RadioRaccon,false,Enum.KeyCode.E)
		game.ReplicatedStorage.NPCCHAT.TalkNpcGuiShower:WaitForChild("RacconShowerUi").Parent = player:WaitForChild("PlayerGui")
	else
		ContextActionService:UnbindAction("RadioRaccon")
		player:WaitForChild("PlayerGui"):WaitForChild("RacconShowerUi").Parent = game.ReplicatedStorage.NPCCHAT.TalkNpcGuiShower
	end
	if (workspace.NPC.JayNpc.HumanoidRootPart.Position - HumanoidRootPart.Position).magnitude < 10 then
		ContextActionService:BindAction("JayMissons",JayMissons,false,Enum.KeyCode.E)
	else
		ContextActionService:UnbindAction("JayMissons")
	end
end

RunService.RenderStepped:Connect(RenderStep)

Can I ask what does the warning say?

13:23:31.859 - Infinite yield possible on ‘Players.static2240.PlayerGui:WaitForChild(“RacconShowerUi”)’

13:23:31.859 - Stack Begin

13:23:31.860 - Script ‘Players.static2240.PlayerGui.ContextActionServiceNpc’, Line 66 - function RenderStep

13:23:31.860 - Stack End

That means that RacconShowerUi wasn’t found in the 5 seconds it searched for.

Ohhhhhhh that make sence, still is there way to get rid of warnings?

You can use this:

repeat wait() until (player:WaitForChild("PlayerGui"):FindFirstChild("RacconShowerUi") ~= nil)
2 Likes

:WaitForChild() warnings shouldn’t bother you if you are sure that the object the script is waiting for will exist eventually.

1 Like

That is completely true, but the user wanted to get rid of warnings.

Why are you hiding this warning? It doesn’t affect you if you’re sure the instance will exist soon.

:WaitForChild() method warns when the argument timeOut isn’t provided and the function exceeds more than 5 seconds, you can use the timeOut argument then check it’s not nil.

local function WaitForChildNoWarn(instance, children_name)
    local children
    repeat 
        children = instance:WaitFirstChild(children_name, 5)
    until children
    return children
end
WaitForChildNoWarn(player:WaitForChild("PlayerGui"), "RaccoonShowerUi")
1 Like