GUI Not Running Error:Infinite Yield

Hello, this is a piece of code I had done for me about a year back. I am no longer in touch with the developer, and am clueless as to the error that is being stated and why. My Job Menu GUI has not been opening lately, and I am not sure why but I get the error:

‘’’ 23:01:53.814 - Infinite yield possible on ‘ReplicatedStorage:WaitForChild(“GameAnalyticsFiltering”)’

23:01:53.814 - Stack Begin

23:01:53.815 - Script ‘Players.momo6097.PlayerScripts.GameAnalyticsClient’, Line 14

23:01:53.815 - Stack End

7

8

9

23:01:56.678 - Infinite yield possible on ‘Players.momo6097:WaitForChild(“leaderstats”)’

23:01:56.679 - Stack Begin

23:01:56.680 - Script ‘Players.momo6097.PlayerGui.Job.GUIHandler’, Line 2’‘’

I know that is a large vague error, and I’m sorry for not being better informed going into this; but I figured the best option was reaching out to the community for some insight. Ill attach the two lines of code:

 `local Player = game.Players.LocalPlayer
local Job = Player:WaitForChild("leaderstats")
local Main = script.Parent.Main
local OpenB = script.Parent.Open
local IsOpen = false
local Debounce = false
local JobDebounce = false

function Open()
	IsOpen = true
	Main:TweenPosition(UDim2.new(0.5,0,0.5,0),"In","Quad",0.5)
end

function Close()
	IsOpen = false
	Main:TweenPosition(UDim2.new(1.5,0,0.5,0),"Out","Quad",1)
end

OpenB.MouseButton1Click:Connect(function()
	if IsOpen == false and Debounce == false then
		Debounce = true
		Open()
		wait(1)
		Debounce = false
	elseif IsOpen == true and Debounce == false then
		Debounce = true
		Close()
		wait(1)
		Debounce = false
	end
end)

for i,v in pairs(Main:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			--if JobDebounce == 0false then
				JobDebounce = true
				game.ReplicatedStorage.Events.ChangeJob:FireServer(v.Name)
				Close()
				wait(60)
				JobDebounce = false
			--end
		end)
	end
end`

Second Piece:
'if script.Parent.ClassName ~= “PlayerScripts” then
error(“GameAnalytics: Disabled client”)
return
end
–Variables
local GameAnalyticsFiltering = game:GetService(“ReplicatedStorage”):WaitForChild(“GameAnalyticsFiltering”)
–local GameAnalyticsSendMessage = game:GetService(“ReplicatedStorage”):WaitForChild(“GameAnalyticsSendMessage”)

    --Services
    local GS = game:GetService("GuiService")
    local UIS = game:GetService("UserInputService")

    --Functions
    function getPlatform()

        if (GS:IsTenFootInterface()) then
            return "Console"
        elseif (UIS.TouchEnabled and not UIS.MouseEnabled) then
            return "Mobile"
        else
            return "Desktop"
        end
    end

    --Filtering
    GameAnalyticsFiltering.OnClientInvoke = getPlatform'

Once again, anything you guys could do in order to help me is greatly appreciated. I'm trying to familiarize myself with code, but I'm not advanced to solve issues. If I gave you insufficient or too much information, please let me know and I'll be happy to provide anything.

Im trying to edit the information (The second piece of code) so I can get it all into the script box; but I’m having a dumb moment so forgive me.

When it says “Infinite yield possible”, that means WaitForChild has taken at least 5 seconds. Since it’s taken that long, it assumes that it’s not going to exist anytime soon and throws a warning. It will keep waiting, though, that’s just a warning.

The issue is likely that you aren’t creating a leaderstats instance under the player.

2 Likes

Ok, do you think that may be why the GUI isn’t working when I click the ScreenGui? And if so, what can I do to fix something like that.

Yeah, it just waits forever for the leaderstats to exist and they never end up existing, meaning the rest of the code never runs. You’d fix this by, well, actually making the leaderstats.

2 Likes

Ok, I have leaderstats or teams created.QUeef
But its still not working, I am totally not familiar as to whether I need to name something “leaderstats” or something like that. Or if that is the correct leaderstats. You’d think after like 6 years I’d know how to solve basic problems, but I’m prone to embarrassing myself.

You just need to name something “leaderstats” and put it in the player using a server sided script. Usually it’s a folder or a model, but it can be anything as far as I’m aware.

2 Likes

Ok that makes sense thank you so much, I’m sorry for being an idiot.

1 Like

Everyone starts somewhere, don’t worry about it.

3 Likes