How does table.find work in this situation?

I have never used table.find before and I am making UI animations inside a ModuleScript and I would like to understand what this script is doing? I have read the documentation for table.find but I am still a little confused.

local OriginalButtonSizes = {}

function module.Setup(Button)
	if not table.find(OriginalButtonSizes, Button) then
		OriginalButtonSizes[Button] = Button.Size
	end
end

What this script is doing, it’s checking if the Button exists in the table, and if not then it creates a dictionary called the Button Name and it contains the Button Size. So it’ll look like this

local OriginalButtonSizes = {
["Button"] = Size
}
1 Like

So I can just write it like this instead of using table.find?

function module.Setup(Button)
	if not OriginalButtonSizes[Button] then
		OriginalButtonSizes[Button] = Button.Size
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.