I have this if statement that I think checks if allrooms has a string that matches a string in sessiondata[plr.UserId].Rooms (a table), but the if statement isn’t going through. Why?
sessiondata[plr.UserId].Rooms only contains the string “Stairs” right now, which matches the string in allrooms.
local allrooms = {["Stairs"] = workspace.StairsBlockade}
for i, v in pairs(allrooms) do
if table.find(sessiondata[plr.UserId].Rooms, v) then
v:Destroy()
end
end
i had printed i and v, and both had returned the same thing last time i printed it, ill try this again though
update: tried it again, didnt change anything
update 2: nevermind, it didnt work because i also changed v:Destroy() to i:Destroy(), setting the find to i and destroy to v fixed it
the i and v are short for “index” and “value” respectively
the index of a table is like the key you need to obtain the value (usually just an increasing int [1, 2, 3, etc])
you can have multiple indexes lead to the same value, but you can’t have the same index lead to multiple values, if that makes sense
yeah thats alright.
there are gonna be a few gotchas to look out for when using dictionaries over tables (fancy vocab for a table with custom indexes), main one is that ipairs isn’t going to work and neither is the # operator to try and get a dictionaries length. somthn to keep in mind since i got stuck on those for a while