WaitForChild never runs, despite the line directly above it being executed

  1. What do you want to achieve?
    I’d like to have the code block shown bellow use waitforchild to return the instance.
  2. What is the issue?
    Even though the lines directly above it execute, and that there are no loops or recursive functions to be found above this line, waitforchild never runs. Even if I set the timeout argument to a small number (I’ve tried setting it from 5 all the way to 0.0001 (you cannot set the time to 0))
  3. What solutions have you tried so far?
    I’ve been asking many of my more luau literate friends why this doesn’t work, and I’ve never gotten an answer, even after sending them the rbxl file.

I’ve also scoured through a bunch of what turned out to be completely irrelevant posts to try and find out what I’ve done incorrectly.

This is the line of code in question:

print("hiii") -- this runs
-- the following doesn't, in fact the entire script stops right here
misceventsfolder:WaitForChild("initiallyloaded",1).OnClientEvent:Connect(function(save: {settingss: {}})
	print(save)
	settingss = save.setingss
	print(settingss)
	
	local categoryindex = 1
	for category,settingsss in ipairs(settingss) do
		local categorytxt = currentcategorygrid.categorytemp:Clone()
		
		categorytxt.Name = category
		categorytxt.Text = category
		categorytxt.LayoutOrder = (#currentcategorygrid:GetChildren() - 2)
		categorytxt.Parent = currentcategorygrid
		
		for name,selected in ipairs(settingsss) do
			local setting = currentcategorygrid.settingtemp:Clone()
			setting.Name = name
			setting.LayoutOrder = (categoryindex + 1)
			setting.name.Text = name
			setting.Visible = true
			
			local optionslist = setting.optionsframe.options
			local optionindex = 1
			
			for name,option in ipairs(settingsinfo[setting.name].options) do
				local optionbutton = (selected == optionindex and optionslist.tempon or optionslist.temp):Clone()
				optionbutton.Text = optionindex
				optionbutton.Name = name
				optionbutton.LayoutOrder = optionindex
				optionbutton.Visible = true
				optionbutton.Parent = optionslist
				optionindex += 1
			end
			
			setting.parent = currentcategorygrid
		end
		
		categoryindex += 1
	end
end)

I’d also like to add that misceventfolder is a real instance, and I’ve done countless checks on it and the “initiallyloaded” event I’m referencing here.

Maybe try.

Local Event = Game.WhereTheItemIs.misceventsfolder:WaitForChild("initiallyloaded")

print("hiii")
Event.OnClientEvent:Connect(function(save: {settingss: {}})
	print(save)
	settingss = save.setingss
	print(settingss)
	
	local categoryindex = 1
	for category,settingsss in ipairs(settingss) do
		local categorytxt = currentcategorygrid.categorytemp:Clone()
		
		categorytxt.Name = category
		categorytxt.Text = category
		categorytxt.LayoutOrder = (#currentcategorygrid:GetChildren() - 2)
		categorytxt.Parent = currentcategorygrid
		
		for name,selected in ipairs(settingsss) do
			local setting = currentcategorygrid.settingtemp:Clone()
			setting.Name = name
			setting.LayoutOrder = (categoryindex + 1)
			setting.name.Text = name
			setting.Visible = true
			
			local optionslist = setting.optionsframe.options
			local optionindex = 1
			
			for name,option in ipairs(settingsinfo[setting.name].options) do
				local optionbutton = (selected == optionindex and optionslist.tempon or optionslist.temp):Clone()
				optionbutton.Text = optionindex
				optionbutton.Name = name
				optionbutton.LayoutOrder = optionindex
				optionbutton.Visible = true
				optionbutton.Parent = optionslist
				optionindex += 1
			end
			
			setting.parent = currentcategorygrid
		end
		
		categoryindex += 1
	end
end)
1 Like

Turns out that I did something incorrect when testing the server side. The instance is already loaded (hence no timeout) and the event is already sent (hence no activation of the event).

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