Table not working properly

local function checkIfEnd(message)

	if message[6] then
		DialogGUI:Destroy()
	end
end

Hello, i’ve been working on a Dialog system lately, but i somehow encountered a problem i have no idea how to resolve:

in this function, i’m trying to find out if the 6. position of the table is “true”. If yes, it should destroy the GUI. But somehow, it also destroys the GUI even if the value is “false”.

I’m getting the table from a module script in a different function.

Looking forward to any help!

1 Like

the table looks like this

messages = {
			"",
			"",
			"",
			"",
			"",
			false
		}

Try to compare message[6] to true, as it might check whether it exists in the table, which it does, and therefore will always be a true statement.

local function checkIfEnd(message)
	if message[6] == true then
		DialogGUI:Destroy()
	end
end

i tried it just to find out that the module script is returning the wrong table

Does it work now at least or is there another issue?
Edit: If my solution hadn’t directly helped with the issue, you can unmark it, just in case.

its a different issue now, thanks for your help

i’ll look into it and create a new topic if needed

1 Like