Volt

fireclickdetector

Triggers a ClickDetector as if it was clicked.

Syntax

fireclickdetector(detector: ClickDetector, distance?: number, event?: string) -> void

Parameters

ParameterTypeDescription
detectorClickDetectorThe ClickDetector to fire
distancenumber?The simulated click distance (default: 0)
eventstring?Event type: "MouseClick", "RightMouseClick", or "MouseHoverEnter/Leave"

Returns

This function does not return a value.

Description

fireclickdetector simulates a click on a ClickDetector, triggering its events without needing to be in range or actually clicking.

Example

-- Find a ClickDetector
local detector = workspace.Button.ClickDetector

-- Fire it
fireclickdetector(detector)

-- Fire with distance
fireclickdetector(detector, 10)

-- Fire right click
fireclickdetector(detector, 0, "RightMouseClick")

Finding and Clicking All

-- Click all ClickDetectors in a model
local function clickAll(parent)
    for _, desc in ipairs(parent:GetDescendants()) do
        if desc:IsA("ClickDetector") then
            fireclickdetector(desc)
        end
    end
end

clickAll(workspace.Shop)

Notes

  • Distance is used for MaxActivationDistance checks in some games
  • Events: "MouseClick" (default), "RightMouseClick", "MouseHoverEnter", "MouseHoverLeave"

On this page