QuestionSolvedNeed help regarding aimbot

Posts 1–4 of 4 · Page 1 of 1
Need help regarding aimbot
hey
recently I have gotten into lua coding but I am a bit stuck,
I want to make my aimbot switch players when I press right alt, but I don't know how to do that.

Code:
hook.Add( "Think", "Aimbot", function()
    local ply = LocalPlayer()
    for k,v in pairs ( player.GetAll() ) do
    
            if v:Alive() and v:IsValid() then
        
                local head = v:LookupBone("ValveBiped.Bip01_Head1")
                local headpos,headang = v:GetBonePosition(head)
            
                if input.IsKeyDown( KEY_LALT ) then
        
                ply:SetEyeAngles((headpos - ply:GetShootPos()):Angle())
                
                if input.IsKeyDown( KEY_RALT) then
                
                end
                    
            end
        end
    end
end)
Right now all it does is attach to a random player around the map and only de-attaches when they die / you kill them.

- - - Updated - - -

Or if possible make it so that instead of locking on to some random around the map it locks onto who ever is in front of you
You'd need to make a separate function that gets all possible targets and puts them in a numerical table. Then in your aimbot code you'd need to check if the key you want is pressed then make it select the n+1th target.

If you wanted to select the target closest to crosshair you'd need to find the dot (Vector:឵Dot(vec)) product between your shootpos (Player:GetShootPos()) and the target's pos (Player:GetPos()) and check to see which one is the smallest.

Also keys like right alt and right shift don't work iirc. If you don't want to get errors when you see NPCs and error models check to see if the target has the ValveBiped.Bip01_Head1 bone, Entity:LookupBone(bone) returns nil if the entity doesn't have the bone.
/Moved to the correct section.
Has been a week since last update/bump after answers, assuming solved.

/Closed.
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us