

1 local traceRes = util.TraceLine ( trace ) - Player Trace part. Here is the whole script if you are the lazy kind.įunction aimbot ( ) - Starting the function local ply = LocalPlayer ( ) - Getting ourselves local trace = util.GetPlayerTrace ( ply ) - Player Trace part. You may also change the bone setting "ValveBiped.Bip01_Head1" to another bone like.Īlso, make sure you write the bones correctly because Garry's Mod crashes when a bone doesn't exists when it's called. I precise you can also rename the script but you also have to change "aimbot" into the new name.Īnd, finally, aim at the bot and you will automatically snap! You may want to create a multiplayer game, open the console (~) and type "bot" to add a bot. So now, you just created your first aimbot, but you need to run it. If in any case the player aims at something at isn't the map, the script will save it as "target" and checks next is "target" is a player, if that is the case, the script gets the head of the player, its position and angle and sets the user's view at the head of the target.įinally, we add the hook which will spam the aimbot function until it finds something. Hook.Add ( "Think", "aimbot",aimbot ) - The hook will spam "aimbot" until it finds a target. Ply:SetEyeAngles ( (targetheadpos - ply:GetShootPos ( ) ):Angle ( ) ) - And finally, we snap our aim to the head of the target. local targetheadpos,targetheadang = target:GetBonePosition (targethead ) - Get the position/angle of the head. local targethead = target:LookupBone ( "ValveBiped.Bip01_Head1" ) - In this aimbot we only aim for the head. if target:IsPlayer ( ) then - But it must be a player. local target = traceRes.Entity - It's obviously an entity. If traceRes.HitNonWorld then - If the aimbot aims at something that isn't the map. "trace" basically gets where the player is aiming and "traceRes" uses "trace" to draw a line from the player to infinity or a wall. Okay so we just created the function but it is not completed, we just added some basics needed for the aimbot to function correctly.

Name your script "a"įunction aimbot ( ) - Starting the function local ply = LocalPlayer ( ) - Getting ourselves local trace = util.GetPlayerTrace ( ply ) - Player Trace part. I'd recommend you to create the lua file in garrysmod/lua folder instead of garrysmod/lua/autorun/client because it is possible that you can type mistakes, and in that case you have to restart GMod.

I remind you this tutorial is only for educational purposes.įor this tutorial you need a brain, some lua knowledge and some maths. This tutorial will show you how to make a basic aimbot.
