Attaching a prop to bones? (SetParentAttachmentMaintainOffest Help)

*Posted this in the What do you need help with thread, but havn’t gotten any replies.

So… Currently I’ve been working on modifying a Riot Shield, and I’ve been having a ton of problems with using SetParentAttachmentMaintainOffest… It works fine, as long as I’m facing one direction… I was trying to research it, and I believe it was something to do with the world position/angle’s relativity to the local position/angle.

Here is the snippet from my code:


function SWEP:Deploy()
    if SERVER then
        if ValidEntity(self.ent) then return end //Makes it not able to spawn multiple entities.
        self.Owner:SetRunSpeed(125)
        self.Owner:SetWalkSpeed(125)
        self:SetColor(255,255,255,0)
        self.ent = ents.Create("prop_physics")
            self.ent:SetModel("models/arleitiss/riotshield/shield.mdl")
            self.ent:SetParent(self.Owner)
            par = self.ent:GetParent()
            hand = par:LookupBone("ValveBiped.Anim_Attachment_RH")
            local pos, ang = par:GetBonePosition( hand )
**            self.ent:SetPos(pos + Vector (-12,-10,-22))
            self.ent:SetAngles(ang + Angle(0,-180,0))
            self.ent:Fire("SetParentAttachmentMaintainOffest", "anim_attachment_RH", 0.01)**
            self.ent:SetCollisionGroup( COLLISION_GROUP_WORLD ) // Lets it not collide to anything but world. Taken from Nocollide 
            self.ent:Spawn()
            self.ent:Activate()
    end
    return true
end

Here are the screenshot’s of what happens:

This is when it is selected while facing the correction direction, and how I want it to look.
http://cloud.steampowered.com/ugc/938123552424315203/06DC0A70E53A547F2337E13DD4FF424DF2C513E1/

This is what happens otherwise…
http://cloud-2.steampowered.com/ugc/938123552424464091/7FFC1C25CBF60973ECEBD42C5E7C0C7BDC3CCBB5/

I would prefer using SetParentAttachment but then I cant change the position/angle and it isn’t attached in the correct position.

Anyone know what I can do to fix it? Im quite new to lua scripting by the way…

Thank you.