A lot of my scripts are set so that they don’t work unless the player spawns in a Pizza model into the workspace. To do this I used waitforchild(“Pizza”) and everything seems to work fine gameplay-wise. However, whenever I launch a test in studios I keep getting spammed:
Infinite yield possible on 'Workspace:WaitForChild(“Pizza”).
I’m wondering if this will cause an issue in any aspect of the game and if I should try and fix it or just leave it as is?
The warning occurs when Instance::WaitForChild has waited for over 5 seconds and you didn’t provide the second optional argument, the timeout. “Infinite yield possible” just means there is a chance your script might wait forever for pizza to appearn.
The debugger is basically telling you that the WaitForChild call may wait infinitely due to the fact that it hadn’t found the instance within a certain amount of time. Make sure the instance actually exists and the name corresponds with the WaitForChild call.
Basically the clickdetectors spawn ingredients for the player’s pizza and it only spawns those ingredients if a pizza exists. So I understand where metryy is coming from but what would be the best solution here since I can’t actually make sure that the pizza actually exists before the player clicks the buttons?
The best solution would be to check if the pizza exists during the click.
Within your clickdetector connection, if FindFirstChild"Pizza" ~= nil (just FindFirstChild"Pizza" alone also works as a conditional itself), you’d run the rest of the code.