How to find attachment instance VIA Constraint

My game has a mechanic where enemy NPCs can latch onto the players mech, they do this by using constraints as welding them will kill the player if the NPC dies.

Right now Im struggling to free up the used attachment on the player where the NPC latches onto.

Here’s the code that frees up the attachment via attributes

function Superordinate:CheckDead()
    local BETA = CS:GetTagged("BETA")
    local Equus = CS:GetTagged("EquusPedis")
    for _,v in pairs(BETA) do

        if v.Humanoid.Health <= 0 then
            if table.find(Equus,v) then
                print(v)
                for __,k in pairs(v.HumanoidRootPart:GetChildren()) do
                    print(k)
                end
                if v.HumanoidRootPart:FindFirstChild("AlignPosition") then
                    print("Has constraint")
                    print(v.HumanoidRootPart.AlignPosition.Attachment0:GetAttribute("Occupied"))
                    v.HumanoidRootPart.AlignPosition.Attachment0:SetAttribute("Occupied",false)
                end
            end
            v:Destroy()
        end
    end
end

The output is this
image

This is the explorer layout

So how can I get the attachment reference via the constraint?

You can try referencing the Attachment1 or Attachment0 property of the constraint.
https://developer.roblox.com/en-us/api-reference/property/Constraint/Attachment0
https://developer.roblox.com/en-us/api-reference/property/Constraint/Attachment1

Thats what I have tried though

v.HumanoidRootPart.AlignPosition.Attachment0

Turns out im just stupid and referenced the wrong attachment. I was almost convinced this was a bug… Im so sorry…

1 Like