How To Indicate A Table Will Be Returned From A Function?

I’m attempting to indicate a return of an array, or table.

This works:

local function Okay(Uhh: number): (number)
    return Uhh
end

image

However, this does not;
image
Or if I use Array, or Dictionary, or anything similar.

My only alternatives I have seen are using the return type {any} like Roblox does;
image

Or {Instance};
image

Or using a string;
image

I’m pretty new to using this API so any pointers would help!

You don’t need to specify which type the function will return. Something like this might work for you:

local function Okay(someNumber)
    return {someNumber}
end

I believe you want something like this:

type tab = { [string] : string | boolean }

Then use “tab” as your return type.

This link might also help:

1 Like

I think the correct type you’re looking for {number}. It is as simple as that.

Arrays - {number}

Dictionaries - {[string]: number}

Structs - {Value: number}

You can mix Dictionaries & Structs

{
	Key: number,
	[string]: number
}

You also don’t need to have the parentheses unless you’re returning a tuple.

2 Likes

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