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

Why am I getting an Infinite yield warning for requiring a module?

Everytime I start the game I get a warning saying Infinite yield possible on 'ServerScriptService:WaitForChild("MathModule")'

m = require(game:GetService("ServerScriptService"):WaitForChild("MathModule"))
local plr = game:GetService("Players").LocalPlayer
while wait(2) do
	local cLevel = plr.leaderstats.Level.Value
	local cEXP = plr.leaderstats.EXP.Value
	local NLEXP = m.nextLevel(cLevel + 1)
	local nEXP = NLEXP - cEXP
	script.Parent.Text = "EXP to next level: "..nEXP
end

9 comments

0

Put the MathModule in Workspace.

0

that did not work I still got the same message

0

It also works in another script just not this one

0

try to put a wait(1) in the first line of script, and remove the :WaitForChild.

0

and be sure to see if the location is correct.

0

I get tons of these warnings too. Should I try to get rid of them or are they just harmless notifications?

0

And no don't try the wait(1) method or it will give you an error

0

Errors are worse than warnings

0

Look at my answer. It's only a warning because it's saying it's been multiple seconds and the child wasn't found. The reason the wait(1) method just shows an error is because the child isn't there.

1 answer

✓ Accepted answer

"Infinite yield possible," is just saying that it has been multiple seconds, and the child hasn't been found yet. It might be that you made a typo somewhere when you were naming the "MathModule," or it might be that you referenced the wrong parent, and the child does not exist. Also, I think "ServerScriptService," doesn't exist when the game is actually running. Since it's probably a local script, you might have to do something creative with remote events to send something to a non-local script that has the same parent as the "MathModule" and do . . .

local mathModule = script.Parent:WaitForChild("MathModule")

To be honest, the easiest way would be to change the parent of the "MathModule" to something other than ServerScriptService if possible.

1 comment

0

By the way, I'm not entirely sure that ServerScriptService doesn't exist after the game starts, but from my experience, all of the stuff in it is moved somewhere that I don't know.

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