Defining a Function in a type

image

I think the problem is obvious in the image, but i want to put a function as a thing in a type definition, but luau doesn’t like it and i couldn’t find any solutions for my problem on the dev forum

Well you’re simply doing it wrong.
You define functions using parentheses, like so:

type myFunction = ()

But that isn’t enough, because you have to define the return type like so:

type myFunction = () -> number

If you want to specify that the function returns nothing, simply but another pair of parentheses, like so:

type myFunction = () -> ()

You can also specify parameters and return types in the parentheses, like so:

type myFunction = (myNumber: number) -> (number, string)

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