skip to Main Content

I am making a FFlag system for my game, I am using MongoDB for it. I wanna check if a certain value in this collection is true or false. Here is my code:

if FFlagsData:FindOne({["allowRebirthing"] = true }) then
    print("Test1")
else if FFlagsData:FindOne({["allowRebirthing"] = false }) then
        print("Test2")
    end
end

image of my collection

2

Answers


  1. Try the following snippet of code:

    if FFlagsData:FindOne({allowRebirthing : true }) then
        print("Test1")
    else if FFlagsData:FindOne({allowRebirthing : false }) then
            print("Test2")
        end
    end
    

    Hope it works.

    Login or Signup to reply.
  2. In Lua, the colon : is typically used for method calls, not for specifying object properties directly. Instead, you should use the equality operator = to specify the property and its value in a Lua table.

    So, in Lua, your query object should be written like this:
    { allowRebirthing = true }

    Plus, removed the square brackets around the field names. MongoDB queries do not need square brackets around field names.

    ({ allowRebirthing = true })

    ({ allowRebirthing = false })

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search