hi , i want to make a table that equal to a diffrent table but its cause error please help me
Heres my script
You can’t check for table equality using the == operator. Use a for loop.
You should probably use a table.foreachi() function to check for whether or not the tables are the same. Alternatively you can simply use a string to hold the values in your case which would be much simpler.
Here, let me make a function to do this!
local function sameTables(t1,t2)
if #t1 ~= #t2 then return false end
for index,value in pairs(t2) do
if t1[index] ~= value then return false end
end
for index,value in pairs(t1) do
if t2[index] ~= value then return false end
end
return true
end
Basically what this does is it loops through table2 and it checks if that index has the same value in table 1. I also added a length check. The loop goes two ways just in the case that one table is shorter than the other to prevent issues.