Yup. "Infinite yield possible on"

The second you read that title you might be thinking “this has been asked many times” because “infinite yield possible” is just a very regular warning that everyone gets.
The thing is that I couldn’t find a post related to my issue, so uh.

Basically this part of my (ModuleScript) would take a value from a folder in ReplicatedStorage and continue the thread:

	local playerAnswer = ReplicatedStorage.PlayerAnswers:WaitForChild(player.Name)
	if playerAnswer.Value == solution then

The StringValue defined above is created using Instance.new() on a LocalScript:

answerInput.FocusLost:Connect(function(enterPressed, inputThatCausedFocusLoss)
	if enterPressed == true and answerInput ~= "" then
		print("Player submitted an answer.")
		local playerAnswers = ReplicatedStorage.PlayerAnswers
		local playerAnswer = Instance.new("StringValue")
		playerAnswer.Parent = playerAnswers
		playerAnswer.Name = Players.LocalPlayer.Name
		EquationRemote:FireServer(playerAnswered, playerAnswer)
	else return

Maybe I’m not smart enough to see why this happens…


Yeah, this is probably going to be an easy fix for anyone, but me, at least. That’s why I’m here.

Thats the issue here…
The string value is not replicated to the server and so, you are waiting forever to find that string value.
A solution would be creating that value on server instead.

Like @EgizianoEG says above, this is because its a local script creating the StringValue instance - which is only visible to the local client - not server.

However, you could simplify this entirely by just including two parameters on the EquationRemote.OnServerEvent.

--you're already Firing this remote with the paramters 'playerAnswered' and 'playerAnswer', so make use of them.
EquationRemote.OnServerEvent:Connect(function(player,playerAnswered, playerAnswer)
	if playerAnswer.Value == solution then

Switched the method for the question as well (it was using a stringvalue too), however, I now get another error, being related to the wrong parameters(?)

if sendAll and isGameRunning then
	for _, player in pairs(Players:GetPlayers()) do
		if table.find(inGamePlayers, player) ~= nil then
			EquationRemote:FireClient(player, equation) -- equation seems to be nil
    sendAll = false -- a boolean im using to allow the server to send a parameter to all players being it the first time

the function i’m using:

local function generateRandomEquation() --- create a random equation
	-- a bunch of stuff here. equation is a string, maybe that's the issue? not sure how return works.
	return equation

^ fixed, had a wrong parameter when getting the server event.

Right, I just put that on ReplicatedStorage, thought the server would see it from there… Thanks anyway.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.