Event connection arguments

Hello, i would like to know if there’s a way to improve events like built-in ones

For example, Roblox signals have this (input: InputObject, gameProcessedEvent: boolean) -

Bindable event only shows (func: (…any) → ()) -

And i, for example, want the first argument to always be a number type, so when i make a function it would automatically be a number (without me adding :number) -

You can create and cast your BindableEvent’s Event property to a custom type:

type CustomEvent = {
    Connect: (self: any, func: (value: number)) -> RBXScriptConnection,
    -- Setup other methods: Once, Wait, ConnectParallel as needed
}

local Bindable = Instance.new("Bindable")
local Event = Bindable.Event :: CustomEvent

Event:Connect(function (value) -- `value` is now automatically cast to type number
    print(value)
end)
1 Like

Thanks a lot! This will be very helpful for making ModuleScripts!

1 Like

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