To set a method to a variable just use dot notation and pass in the class as the first variable (self)
Ex:
function Class:DoSomething(...)
end
local DoSomething = Class.DoSomething
--Use case
DoSomething(Class, ...)
--Passing in the class acts like how methods automatically pass self
Edit: There’s no other way to save a method to a variable other than this (I think)
Other than what you have shown where you pass in the class manually or creating a function that calls the method and passes your arguments, there’s really no other way.
You could create a higher order function that returns a function that automatically passes in the object as the first value
local function CreateFunction(Function, Object)
return function(...)
Function(Object, ...)
end
end
local foo = CreateFunction(TweenService.GetValue, TweenService)
foo(alpha, easing, direction)
Not as convenient as local foo = TweenService:GetValue but probably as close as you’re gonna get