I'm writing a script which rely's a ton on the number of objects in a table to properly tween them, but when a function is called which checks #mytable, the result it gets is always 0, and despite the fact that the table does have data in it (the script adds a object to the table before it runs said function, so the table must be full), it always returns 0, so if any one knows what the issue is please tell me.
Here is a script which may help diagnose the issue:
local mytable = {}
function getIncerement()
print(#mytable) --always outputs 0
if #mytable > 1 then
return 0.5
else
return 0
end
end
function func(name)
local obj --I would put my object here
mytable[name] = obj
local i = getIncerement()
obj.Position = UDim2.new(0,0,i,0) --just pretend obj had a udim2 property
end
func("abc")
wait(1)
func("dfg")
Aaaaaaaaaand ya my issue is when the getIncerement() function is called always #mytable returns 0, if you can figure out the issue great, because this is threatening the cleanliness of a script of mine.
Thanks ~chabad360

7 comments
You can not name a table table, or else the game will assume you're referring to the "table" functions.
it's also important to remember that the #x syntax won't work as might be expected when dealing with dictionaries
I know this is just for the question, but it's not like that in the actual script
IT CERATINLY WOULD BE GREAT IF WE GOT THE SCRIPT
Well we can't exactly help you without any script....
I'll put a script which has good resemblance to the real one, but I don't know if it will help...
Put the actual one, this still doesn't make complete sense!