Skip to main content

HoldableInputModel

Tracks hold state for an input. Handles the timing logic and exposes observables for hold progress.

local holdableInputModel = HoldableInputModel.new(1.5)
-- Or set it later:
-- holdableInputModel:SetMaxHoldDuration(1.5)

maid:GiveTask(holdableInputModel.HoldReleased:Connect(function(holdPercent)
	print("Released at", holdPercent)
end))

-- When input begins
holdableInputModel:StartHold()

-- When input ends
holdableInputModel:StopHold()

Properties

HoldStarted

HoldableInputModel.HoldStarted: Signal<>

Fires when a hold begins

HoldUpdated

HoldableInputModel.HoldUpdated: Signal<number>

Fires when the hold percent updates

HoldReleased

HoldableInputModel.HoldReleased: Signal<number>

Fires when a hold is released with the final hold percent

Functions

new

HoldableInputModel.new(
maxHoldDurationnumber?--

Optional max hold duration in seconds (defaults to 1)

) → HoldableInputModel

Constructs a new HoldableInputModel

SetMaxHoldDuration

HoldableInputModel.SetMaxHoldDuration(
durationnumber | Observable<number>
) → MaidTask

Sets the maximum hold duration in seconds

GetMaxHoldDuration

HoldableInputModel.GetMaxHoldDuration(selfHoldableInputModel) → number

Gets the maximum hold duration

ObserveMaxHoldDuration

HoldableInputModel.ObserveMaxHoldDuration(selfHoldableInputModel) → Observable<number>

Observes the maximum hold duration

ObserveHoldPercent

HoldableInputModel.ObserveHoldPercent(selfHoldableInputModel) → Observable<number>

Observes the current hold percent (0-1)

GetHoldPercent

HoldableInputModel.GetHoldPercent(selfHoldableInputModel) → number

Gets the current hold percent (0-1)

ObserveIsHolding

HoldableInputModel.ObserveIsHolding(selfHoldableInputModel) → Observable<boolean>

Observes whether currently holding

IsHolding

HoldableInputModel.IsHolding(selfHoldableInputModel) → boolean

Returns whether currently holding

StartHold

HoldableInputModel.StartHold(selfHoldableInputModel) → ()

Starts tracking a hold. Call this when input begins.

StopHold

HoldableInputModel.StopHold(selfHoldableInputModel) → ()

Stops tracking a hold and fires HoldReleased with the final percent. Call this when input ends.

CancelHold

HoldableInputModel.CancelHold(selfHoldableInputModel) → ()

Cancels a hold without firing HoldReleased. Use this when the hold should be aborted (e.g., interrupted by stun).

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new HoldableInputModel",
            "params": [
                {
                    "name": "maxHoldDuration",
                    "desc": "Optional max hold duration in seconds (defaults to 1)",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "SetMaxHoldDuration",
            "desc": "Sets the maximum hold duration in seconds",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                },
                {
                    "name": "duration",
                    "desc": "",
                    "lua_type": "number | Observable<number>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "MaidTask"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 96,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "GetMaxHoldDuration",
            "desc": "Gets the maximum hold duration",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 108,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "ObserveMaxHoldDuration",
            "desc": "Observes the maximum hold duration",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 117,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "ObserveHoldPercent",
            "desc": "Observes the current hold percent (0-1)",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "GetHoldPercent",
            "desc": "Gets the current hold percent (0-1)",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 135,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "ObserveIsHolding",
            "desc": "Observes whether currently holding",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<boolean>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 144,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "IsHolding",
            "desc": "Returns whether currently holding",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 153,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "StartHold",
            "desc": "Starts tracking a hold. Call this when input begins.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 160,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "StopHold",
            "desc": "Stops tracking a hold and fires HoldReleased with the final percent.\nCall this when input ends.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 194,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "CancelHold",
            "desc": "Cancels a hold without firing HoldReleased.\nUse this when the hold should be aborted (e.g., interrupted by stun).",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HoldableInputModel"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 202,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "HoldStarted",
            "desc": "Fires when a hold begins\n\t",
            "lua_type": "Signal<>",
            "source": {
                "line": 71,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "HoldUpdated",
            "desc": "Fires when the hold percent updates\n\t",
            "lua_type": "Signal<number>",
            "source": {
                "line": 78,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        },
        {
            "name": "HoldReleased",
            "desc": "Fires when a hold is released with the final hold percent\n\t",
            "lua_type": "Signal<number>",
            "source": {
                "line": 85,
                "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
            }
        }
    ],
    "types": [],
    "name": "HoldableInputModel",
    "desc": "Tracks hold state for an input. Handles the timing logic\nand exposes observables for hold progress.\n\n```lua\nlocal holdableInputModel = HoldableInputModel.new(1.5)\n-- Or set it later:\n-- holdableInputModel:SetMaxHoldDuration(1.5)\n\nmaid:GiveTask(holdableInputModel.HoldReleased:Connect(function(holdPercent)\n\tprint(\"Released at\", holdPercent)\nend))\n\n-- When input begins\nholdableInputModel:StartHold()\n\n-- When input ends\nholdableInputModel:StopHold()\n```",
    "source": {
        "line": 24,
        "path": "src/inputkeymaputils/src/Shared/HoldableInputModel.lua"
    }
}