Not working if statments when used in code

My issue not working but it seems logic
I tried many solutions none worked
Output says that its table expected got boolean

function MapVoting(ProioritizedMap,Person)
local function cool ()
if table.find(MoonMapChoosers,Person) then
return MoonMapChoosers
elseif table.find(SkyMapChoosers,Person) then
return SkyMapChoosers
elseif table.find(RockMapChoosers,Person) then
return RockMapChoosers
else
return false
end
end
cool()
local PreviousVotedMap = cool()
print(PreviousVotedMap)
if PreviousVotedMap == RockMapChoosers or SkyMapChoosers or MoonMapChoosers then
for i,v in pairs(PreviousVotedMap) do
if v == Person then
table.remove(PreviousVotedMap,i)
table.insert(ProioritizedMap, Person)
print(i)
elseif ProioritizedMap == false then
table.insert(ProioritizedMap, Person)
print(Person)
end
end
end
end

but look please I am depserate I need help

A few tips:

  1. Code Formatting Etiquette
  2. Use code blocks
  3. Tell us which line the error is at

People are less inclined to put in the effort to help you if you yourself don’t put in any effort

This is how you make code blocks:

```
print(“Hello world!”)
```

Result:

print("Hello world!")

I’m not really sure how are you determining the players, however since it’s expecting a table but you gave it a boolean, I can’t really help you much based on the script you gave me.

However, make a check and see if the function returns false.

function MapVoting(ProioritizedMap,Person)

local function cool ()
    if table.find(MoonMapChoosers,Person) then
        return MoonMapChoosers
    elseif table.find(SkyMapChoosers,Person) then
        return SkyMapChoosers
    elseif table.find(RockMapChoosers,Person) then
        return RockMapChoosers
    else
        return false
    end
end

cool()

if cool() then
local PreviousVotedMap = cool()
print(PreviousVotedMap)
if PreviousVotedMap == RockMapChoosers or SkyMapChoosers or MoonMapChoosers then
    for i,v in pairs(PreviousVotedMap) do
        if v == Person then
            table.remove(PreviousVotedMap,i)
            table.insert(ProioritizedMap, Person)
            print(i)
        elseif ProioritizedMap == false then
            table.insert(ProioritizedMap, Person)
            print(Person)
        end
    end
end
end
end

Since the previousvotemap is a table, you should use {}

Im deterniminging the players from hit.parent in a event

Allso I already did a check, check my code