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
This is the explorer layout
So how can I get the attachment reference via the constraint?