How to make function with a function as an argument.

I would love to learn how to make a function with function as an argument, like a nested function. I’ve searched for an hour now, and i still havn’t found anything helpful, so i was hoping you guys could help me.
You know when you fx. want to make a timer, it looks like this.

timer.Create(identifier, delay, repetitions, func)

I was trying to find the source to this function in gmods files, but i couldn’t.

This is what i am looking for.

local function DoSomething(func)
	--Excacute the argumented function


No matter how i wrap my mind around it, i just cant figure it out. Anyone know how to do this? :slight_smile:

You basically answered your own question. Assuming the proper checks to make sure that first argument is a function, you’d just do:

local function DoSomething(func)
	func( )

I feel stupid now xD Thanks for the reply my friend :slight_smile: Worked like a charm :slight_smile: