-- If the entity belongs to a ship if shipId then -- Check to see if the entity that was hit was a mast. -- If it was, break the mast. local mast = FindMast(target) if mast then if (target:Health() - amount) <= 50 then local mastEnt = ents.FindByName("ship" .. shipId .. "weldmast" .. mast) if mastEnt then constraint.RemoveAll( mastEnt ) Ships[shipId].status.masts = Ships[shipId].status.masts - 1 CheckIfSinking(shipId) Ships[shipId].forward:SetKeyValue("force", SpeedPerMast * Ships[shipId].status.masts) Ships[shipId].backward:SetKeyValue("force", SpeedPerMast * Ships[shipId].status.masts) if attacker:IsPlayer() then attacker:PS_GivePoints(PS.Config.MastBreakGold) end end end end
The above code is my attempt at removing constraints when a mast in the gamemode Pirate Ship Wars is shot at instead of simply breaking using Ent:Fire.
However, the mast is still welded together when the entity has less than 50 HP.
So my question is, what am I doing wrong?