Error trying to FindFirstChild on a ModuleScript Table

Hi. I just wanted to know if you’re able to use FindFirstChild in a ModuleScript for a table. I getting an error but I want my code to do something if the table for that specific zone is not found. Any solutions?

image
If you need any more code let me know.

Thanks,
Keiron.

local zoneData
for index, value in pairs(config.RankLock) do
    if value == zone then
         zoneData = value
    end
end

It would be useful if you provided what the RankLock module looked like / was returning

image
This is the table

What are you trying to accomplish by using FindFirstChild then? Also have you tried my solution?

So, if it finds the table, it checks if the value “Enabled” is either true or false, if it’s true it only allows the user to click the switch from the GroupID and Rank set in the module script, if it’s set to false it allows any user to click it without being in the group.

I’m just trying your solution now, I’ll let you know how it goes, thanks.

If that doesn’t work try this:

local zoneData
for index, value in pairs(config.RankLock) do
    if index == zone then
         zoneData = value
    end
end

Do I still use the code below or?

if zonedata then
elseif not zonedata then
end

Yea that should still be fine, just replace the local zonedata = … line

Okay so it’s doing something, but not the correct thing. For the elseif I have a warn function to warn if the table doesn’t exist. The table does exist but it’s saying it doesnt. I’ll show you the script.

image

Try printing zonedata and see what it prints after the for loop

image
It’s printing the tables.

It’s still saying the tables don’t exist tho, I don’t understand why it’s doing it.

Hi thank you so much. I got it to work!

1 Like

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