firetouchinterest

Triggers a Touched or TouchEnded event between two parts.

Syntax

firetouchinterest(part: BasePart, target: BasePart, toggle: boolean | number) -> ()

Parameters

ParameterTypeDescription
partBasePartThe touching part
targetBasePartThe part to touch
toggleboolean or numberfalse/0 starts touch; true/1 ends touch

Returns

This function does not return a value.

Description

firetouchinterest simulates a touch between two parts, firing the Touched or TouchEnded events without physical contact.

Example

local firstPart = Instance.new("Part")
firstPart.Parent = workspace

local targetPart = Instance.new("Part")
targetPart.Parent = workspace

-- Simulate touch start
firetouchinterest(firstPart, targetPart, 0)

-- Simulate touch end
firetouchinterest(firstPart, targetPart, 1)

firstPart:Destroy()
targetPart:Destroy()

Touch and Release

local function touch(part, target)
    firetouchinterest(part, target, 0) -- Touch
    task.wait()
    firetouchinterest(part, target, 1) -- Release
end

local character = game:GetService("Players").LocalPlayer.Character
local rootPart = character and character:FindFirstChild("HumanoidRootPart")
local targetPart = workspace:FindFirstChild("TouchTarget")

if rootPart and targetPart and targetPart:IsA("BasePart") then
    touch(rootPart, targetPart)
end

Collecting Items

local function collectTouchParts(parent)
    local character = game:GetService("Players").LocalPlayer.Character
    local hrp = character and character:FindFirstChild("HumanoidRootPart")
    if not hrp then
        return
    end

    for _, part in ipairs(parent:GetChildren()) do
        if part:IsA("BasePart") then
            firetouchinterest(hrp, part, 0)
            task.wait()
            firetouchinterest(hrp, part, 1)
        end
    end
end

Notes

  • Toggle: false or 0 starts touch; true or 1 ends it
  • Both events should be fired for proper simulation