#Infinite yield on WaitForChild [Solved]

1 messages · Page 1 of 1 (latest)

brazen slate
#

hey, just making a few test scripts to familiarize myself with roblox studio and interacting with the client/server environment, and i get an infinite yield on the WaitForChild on my ModuleScript. i checked online, and they say that it could be from a misspelling, but i'm checking my code, and there doesn't seem to be anything that causes the issue. noting i am loosely following the module tutorial on the official documentation site: https://create.roblox.com/docs/scripting/module

i have 2 files- TestModule, under ReplicatedStorage:

local pizza = {}

local size = {
    large = 12,
    medium = 8,
    small = 4
}

function pizza.getPrice(size)
    local price = pizza.size[size] * 2
    return price
end

return pizza

and ModuleTaker, under ServerScriptStorage

print("testingpleasework")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local pizza = require(ReplicatedStorage:WaitForChild("pizza"))
local price = pizza.getPrice("large")
print("The price is ")

"testingpleasework" is printed right as i spawn in, afterward, there's a long wait, then i get the infinite yield error. technically, i have another script under ServerScriptStorage, but that one's unrelated to everything else.
what could be causing the error?

#

okay, so i was dumb and i'm 90% sure the issue is that i shoulda named the script "pizza" instead of "ModuleTaker". unfortunately, i don't think the tutorial mentioned it anywhere, so it took me some trial and error to figure out. i don't know if that's the exact problem however, since i'm getting more errors.

i'll note if this is solved once i get everything working and there are no more errors

#

ok, just got it to work. i had a few extra errors, like calling the function "pizza.size" instead of just "size", and naming the function input and table the same thing, but i can now say this fully works

#

Infinite yield on WaitForChild [Solved]

#

ngl i'm not sure if i should unmark this as solved or just make a new post if i have more issues with this project

hoary tinsel
brazen slate
#

i guess that's an alternative to i said in the solutions :P
i mainly wanted to follow the tutorial's method tho e