Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Calling a function on a table, and how does this code work?

function module:GetDatabase(sheet)
	local database = {}
	function database:PostAsync(key, value)
		return doPost(sheet, key, value)
	end
	function database:GetAsync(key)
		return doGet(sheet, key)
	end
	return database
end

So, from my understanding, whenever PostAsync() is called, doPost is returned, and whenever GetAsync() is called, doGet is returned? Am I correct in this understanding?

Also, functions are being called on the table? This code is confusing me for some reason.

1 comment

0

To clarify: this is someone else's code that I'm trying to learn from. I'm sure you figured that out, though.

1 answer

✓ Accepted answer

Whenever you call :PostAsync() on the module, which is what the script is in, it'll return a function doPost() that I'm assuming uses PostAsync. This looks like code for a Sheets API.

2 comments

0

I've been using and learning from his source code and trying to make it into an idea I've had for a while. Kinda excited about this project.

This discussion is preserved as it was. New answers, comments, and votes are closed.