[HELP] Attaching Object to Player

object

#1

Hi, Im working on an action menu atm but, I’m having some problem with

AttachEntityToEntity("prop_riot_shield", GetPlayerPed(PlayerId()), GetPedBoneIndex(GetPlayerPed(PlayerId()), 61163), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1)

It doesnt seem to do anything. I tried to debug it with print('Works?') Nothing prints.
I trigger it through this but I dont think it works.
elseif WarMenu.Button('Shield') then TriggerEvent("shield")
Any help is appreciated. Thanks!


#2

I use this:

    local shield = CreateObject(GetHashKey(prop), pedPos.x, pedPos.y, pedPos.z, 1, 1, 1)
    shieldEntity = shield
    AttachEntityToEntity(shieldEntity, ped, GetEntityBoneIndexByName(ped, "IK_L_Hand"), 0.0, -0.05, -0.10, -30.0, 180.0, 40.0, 0, 0, 1, 0, 0, 1)

And of course define pedPos :slight_smile:


#4

Wait, It spawns the shield like 20 ft infront of you and Is not attached?


#5

Hmm, you sure you defined pedPos properly? I mean… it works for me xD


#6

I do however, use it with an anim, that might be the trick.


#7

Can I see your whole code with the Attached Prop?


#8

Try look at this, I use some snippets from Xander’s code here: