How do I add make models ragdoll?

I am working on a SWEP which basically shoots out ragdolls, everything seemed fine until the ragdolls don’t actually ragdoll, instead, they do the A-pose, can someone help me out?

Do you use the prop_ragdoll entity? If this is the case, can you show the code you currently use to spawn the ragdolls?

self:throw_attack(“models/Humans/Group01/male_07.mdl”)
self:throw_attack(“models/Humans/Group01/male_09.mdl”)
self:throw_attack(“models/Humans/Group01/male_08.mdl”)
self:throw_attack(“models/Humans/Group01/male_06.mdl”)
self:throw_attack(“models/Humans/Group01/male_05.mdl”)
end

that is the code I use

And the code of the function? Your current code doesn’t say much.

its actually this: //Throw a wooden chair on secondary attack
function SWEP:SecondaryAttack()
//Call the throw attack function, this time with the wooden chair model
self:throw_attack(“models/Humans/Group01/male_07.mdl”)
self:throw_attack(“models/Humans/Group01/male_09.mdl”)
self:throw_attack(“models/Humans/Group01/male_08.mdl”)
self:throw_attack(“models/Humans/Group01/male_06.mdl”)
self:throw_attack(“models/Humans/Group01/male_05.mdl”)
end

i used a tutorial from a website i forgot

No, the code for the WEAPON:throw_attack function.

just see all the code: --********************************************************

--DESCRIPTION:
	--This script is meant for experienced scripters 
	--that KNOW WHAT THEY ARE DOING. Don't come to me 
	--with basic Lua questions.
	
	--Just copy into your SWEP or SWEP base of choice
	--and merge with your own code.
	
	--The SWEP.VElements, SWEP.WElements and
	--SWEP.ViewModelBoneMods tables are all optional
	--and only have to be visible to the client.

–********************************************************/
– View Model And World Model Code
function SWEP:Initialize()

--other initialize code goes here

if CLIENT then

	SWEP.HoldType = "rpg"

SWEP.ViewModelFOV = 69.748743718593
SWEP.ViewModelFlip = false
SWEP.UseHands = false
SWEP.ViewModel = “models/weapons/v_rpg.mdl”
SWEP.WorldModel = “models/weapons/w_rocket_launcher.mdl”
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBoneMods = {}
SWEP.IronSightsPos = Vector(1.559, 0, -1.04)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.VElements = {
[“4”] = { type = “Model”, model = “models/props_combine/combine_intmonitor003.mdl”, bone = “base”, rel = “”, pos = Vector(-3.458, 0, 8.395), angle = Angle(0, 0, 0), size = Vector(0.164, 0.164, 0.164), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“1”] = { type = “Model”, model = “models/props_c17/furnitureboiler001a.mdl”, bone = “base”, rel = “”, pos = Vector(-2.47, -0.494, 5.432), angle = Angle(0, 0, 0), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“5”] = { type = “Model”, model = “models/props_wasteland/controlroom_monitor001b.mdl”, bone = “base”, rel = “”, pos = Vector(8.395, 1.48, 5.432), angle = Angle(0, 0, 0), size = Vector(0.225, 0.225, 0.225), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“2”] = { type = “Model”, model = “models/Humans/Group01/male_07.mdl”, bone = “base”, rel = “”, pos = Vector(1.48, 0.493, 8.395), angle = Angle(81.111, 1.11, -94.445), size = Vector(0.101, 0.101, 0.101), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“6”] = { type = “Model”, model = “models/props_wasteland/controlroom_monitor001b.mdl”, bone = “base”, rel = “”, pos = Vector(7.407, 0, 0), angle = Angle(-78.889, 0, 0), size = Vector(0.164, 0.164, 0.164), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“3”] = { type = “Model”, model = “models/props_phx/huge/tower.mdl”, bone = “base”, rel = “”, pos = Vector(-0.494, 0, 12.345), angle = Angle(0, 0, 0), size = Vector(0.009, 0.009, 0.009), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} }
}
SWEP.WElements = {
[“4”] = { type = “Model”, model = “models/props_combine/combine_intmonitor003.mdl”, bone = “ValveBiped.Bip01_R_Hand”, rel = “”, pos = Vector(0, 0, -10), angle = Angle(0, 0, 0), size = Vector(0.164, 0.164, 0.164), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“1”] = { type = “Model”, model = “models/props_c17/furnitureboiler001a.mdl”, bone = “ValveBiped.Bip01_R_Hand”, rel = “”, pos = Vector(5, 0, -10), angle = Angle(-121.112, 0, 0), size = Vector(0.287, 0.287, 0.287), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“5”] = { type = “Model”, model = “models/props_wasteland/controlroom_monitor001b.mdl”, bone = “ValveBiped.Bip01_R_Hand”, rel = “”, pos = Vector(10, 0, -10), angle = Angle(0, 0, 0), size = Vector(0.225, 0.225, 0.225), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“2”] = { type = “Model”, model = “models/Humans/Group01/male_07.mdl”, bone = “ValveBiped.Bip01_R_Hand”, rel = “”, pos = Vector(15, 0, -10), angle = Angle(0, 0, 0), size = Vector(0.101, 0.101, 0.101), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“6”] = { type = “Model”, model = “models/props_wasteland/controlroom_monitor001b.mdl”, bone = “ValveBiped.Bip01_R_Hand”, rel = “”, pos = Vector(20, 0, -10), angle = Angle(0, 0, 0), size = Vector(0.164, 0.164, 0.164), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} },
[“3”] = { type = “Model”, model = “models/props_phx/huge/tower.mdl”, bone = “ValveBiped.Bip01_R_Hand”, rel = “”, pos = Vector(17.284, 0, -10), angle = Angle(0, 0, 0), size = Vector(0.009, 0.009, 0.009), color = Color(255, 255, 255, 255), surpresslightning = false, material = “”, skin = 0, bodygroup = {} }
}

	-- Create a new table for every weapon instance
	self.VElements = table.FullCopy( self.VElements )
	self.WElements = table.FullCopy( self.WElements )
	self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )

	self:CreateModels(self.VElements) // create viewmodels
	self:CreateModels(self.WElements) // create worldmodels
	
	-- init view model bone build function
	if IsValid(self.Owner) then
		local vm = self.Owner:GetViewModel()
		if IsValid(vm) then
			self:ResetBonePositions(vm)
			
			-- Init viewmodel visibility
			if (self.ShowViewModel == nil or self.ShowViewModel) then
				vm:SetColor(Color(255,255,255,255))
			else
				-- we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
				vm:SetColor(Color(255,255,255,1))
				-- ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
				-- however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing
				vm:SetMaterial("Debug/hsv")			
			end
		end
	end
	
end

end

function SWEP:Holster()

if CLIENT and IsValid(self.Owner) then
	local vm = self.Owner:GetViewModel()
	if IsValid(vm) then
		self:ResetBonePositions(vm)
	end
end

return true

end

function SWEP:OnRemove()
self:Holster()
end

if CLIENT then

SWEP.vRenderOrder = nil
function SWEP:ViewModelDrawn()
	
	local vm = self.Owner:GetViewModel()
	if !IsValid(vm) then return end
	
	if (!self.VElements) then return end
	
	self:UpdateBonePositions(vm)

	if (!self.vRenderOrder) then
		
		-- we build a render order because sprites need to be drawn after models
		self.vRenderOrder = {}

		for k, v in pairs( self.VElements ) do
			if (v.type == "Model") then
				table.insert(self.vRenderOrder, 1, k)
			elseif (v.type == "Sprite" or v.type == "Quad") then
				table.insert(self.vRenderOrder, k)
			end
		end
		
	end

	for k, name in ipairs( self.vRenderOrder ) do
	
		local v = self.VElements[name]
		if (!v) then self.vRenderOrder = nil break end
		if (v.hide) then continue end
		
		local model = v.modelEnt
		local sprite = v.spriteMaterial
		
		if (!v.bone) then continue end
		
		local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
		
		if (!pos) then continue end
		
		if (v.type == "Model" and IsValid(model)) then

			model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
			ang:RotateAroundAxis(ang:Up(), v.angle.y)
			ang:RotateAroundAxis(ang:Right(), v.angle.p)
			ang:RotateAroundAxis(ang:Forward(), v.angle.r)

			model:SetAngles(ang)
			--model:SetModelScale(v.size)
			local matrix = Matrix()
			matrix:Scale(v.size)
			model:EnableMatrix( "RenderMultiply", matrix )
			
			if (v.material == "") then
				model:SetMaterial("")
			elseif (model:GetMaterial() != v.material) then
				model:SetMaterial( v.material )
			end
			
			if (v.skin and v.skin != model:GetSkin()) then
				model:SetSkin(v.skin)
			end
			
			if (v.bodygroup) then
				for k, v in pairs( v.bodygroup ) do
					if (model:GetBodygroup(k) != v) then
						model:SetBodygroup(k, v)
					end
				end
			end
			
			if (v.surpresslightning) then
				render.SuppressEngineLighting(true)
			end
			
			render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
			render.SetBlend(v.color.a/255)
			model:DrawModel()
			render.SetBlend(1)
			render.SetColorModulation(1, 1, 1)
			
			if (v.surpresslightning) then
				render.SuppressEngineLighting(false)
			end
			
		elseif (v.type == "Sprite" and sprite) then
			
			local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
			render.SetMaterial(sprite)
			render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
			
		elseif (v.type == "Quad" and v.draw_func) then
			
			local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
			ang:RotateAroundAxis(ang:Up(), v.angle.y)
			ang:RotateAroundAxis(ang:Right(), v.angle.p)
			ang:RotateAroundAxis(ang:Forward(), v.angle.r)
			
			cam.Start3D2D(drawpos, ang, v.size)
				v.draw_func( self )
			cam.End3D2D()

		end
		
	end
	
end

SWEP.wRenderOrder = nil
function SWEP:DrawWorldModel()
	
	if (self.ShowWorldModel == nil or self.ShowWorldModel) then
		self:DrawModel()
	end
	
	if (!self.WElements) then return end
	
	if (!self.wRenderOrder) then

		self.wRenderOrder = {}

		for k, v in pairs( self.WElements ) do
			if (v.type == "Model") then
				table.insert(self.wRenderOrder, 1, k)
			elseif (v.type == "Sprite" or v.type == "Quad") then
				table.insert(self.wRenderOrder, k)
			end
		end

	end
	
	if (IsValid(self.Owner)) then
		bone_ent = self.Owner
	else
		--when the weapon is dropped
		bone_ent = self
	end
	
	for k, name in pairs( self.wRenderOrder ) do
	
		local v = self.WElements[name]
		if (!v) then self.wRenderOrder = nil break end
		if (v.hide) then continue end
		
		local pos, ang
		
		if (v.bone) then
			pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
		else
			pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
		end
		
		if (!pos) then continue end
		
		local model = v.modelEnt
		local sprite = v.spriteMaterial
		
		if (v.type == "Model" and IsValid(model)) then

			model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
			ang:RotateAroundAxis(ang:Up(), v.angle.y)
			ang:RotateAroundAxis(ang:Right(), v.angle.p)
			ang:RotateAroundAxis(ang:Forward(), v.angle.r)

			model:SetAngles(ang)
			--model:SetModelScale(v.size)
			local matrix = Matrix()
			matrix:Scale(v.size)
			model:EnableMatrix( "RenderMultiply", matrix )
			
			if (v.material == "") then
				model:SetMaterial("")
			elseif (model:GetMaterial() != v.material) then
				model:SetMaterial( v.material )
			end
			
			if (v.skin and v.skin != model:GetSkin()) then
				model:SetSkin(v.skin)
			end
			
			if (v.bodygroup) then
				for k, v in pairs( v.bodygroup ) do
					if (model:GetBodygroup(k) != v) then
						model:SetBodygroup(k, v)
					end
				end
			end
			
			if (v.surpresslightning) then
				render.SuppressEngineLighting(true)
			end
			
			render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
			render.SetBlend(v.color.a/255)
			model:DrawModel()
			render.SetBlend(1)
			render.SetColorModulation(1, 1, 1)
			
			if (v.surpresslightning) then
				render.SuppressEngineLighting(false)
			end
			
		elseif (v.type == "Sprite" and sprite) then
			
			local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
			render.SetMaterial(sprite)
			render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
			
		elseif (v.type == "Quad" and v.draw_func) then
			
			local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
			ang:RotateAroundAxis(ang:Up(), v.angle.y)
			ang:RotateAroundAxis(ang:Right(), v.angle.p)
			ang:RotateAroundAxis(ang:Forward(), v.angle.r)
			
			cam.Start3D2D(drawpos, ang, v.size)
				v.draw_func( self )
			cam.End3D2D()

		end
		
	end
	
end

function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
	
	local bone, pos, ang
	if (tab.rel and tab.rel != "") then
		
		local v = basetab[tab.rel]
		
		if (!v) then return end
		
		-- Technically, if there exists an element with the same name as a bone
		-- you can get in an infinite loop. Let's just hope nobody's that stupid.
		pos, ang = self:GetBoneOrientation( basetab, v, ent )
		
		if (!pos) then return end
		
		pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
		ang:RotateAroundAxis(ang:Up(), v.angle.y)
		ang:RotateAroundAxis(ang:Right(), v.angle.p)
		ang:RotateAroundAxis(ang:Forward(), v.angle.r)
			
	else
	
		bone = ent:LookupBone(bone_override or tab.bone)

		if (!bone) then return end
		
		pos, ang = Vector(0,0,0), Angle(0,0,0)
		local m = ent:GetBoneMatrix(bone)
		if (m) then
			pos, ang = m:GetTranslation(), m:GetAngles()
		end
		
		if (IsValid(self.Owner) and self.Owner:IsPlayer() and 
			ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
			ang.r = -ang.r // Fixes mirrored models
		end
	
	end
	
	return pos, ang
end

function SWEP:CreateModels( tab )

	if (!tab) then return end

	--Create the clientside models here because Garry says we can't do it in the render hook
	for k, v in pairs( tab ) do
		if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and 
				string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
			
			v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
			if (IsValid(v.modelEnt)) then
				v.modelEnt:SetPos(self:GetPos())
				v.modelEnt:SetAngles(self:GetAngles())
				v.modelEnt:SetParent(self)
				v.modelEnt:SetNoDraw(true)
				v.createdModel = v.model
			else
				v.modelEnt = nil
			end
			
		elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite) 
			and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
			
			local name = v.sprite.."-"
			local params = { ["$basetexture"] = v.sprite }
			--make sure we create a unique name based on the selected options
			local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
			for i, j in pairs( tocheck ) do
				if (v[j]) then
					params["$"..j] = 1
					name = name.."1"
				else
					name = name.."0"
				end
			end

			v.createdSprite = v.sprite
			v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
			
		end
	end
	
end

local allbones
local hasGarryFixedBoneScalingYet = false

function SWEP:UpdateBonePositions(vm)
	
	if self.ViewModelBoneMods then
		
		if (!vm:GetBoneCount()) then return end
		
		// !! WORKAROUND !! //
		// We need to check all model names :/
		local loopthrough = self.ViewModelBoneMods
		if (!hasGarryFixedBoneScalingYet) then
			allbones = {}
			for i=0, vm:GetBoneCount() do
				local bonename = vm:GetBoneName(i)
				if (self.ViewModelBoneMods[bonename]) then 
					allbones[bonename] = self.ViewModelBoneMods[bonename]
				else
					allbones[bonename] = { 
						scale = Vector(1,1,1),
						pos = Vector(0,0,0),
						angle = Angle(0,0,0)
					}
				end
			end
			
			loopthrough = allbones
		end
		// !! ----------- !! //
		
		for k, v in pairs( loopthrough ) do
			local bone = vm:LookupBone(k)
			if (!bone) then continue end
			
			--!! WORKAROUND !! --
			local s = Vector(v.scale.x,v.scale.y,v.scale.z)
			local p = Vector(v.pos.x,v.pos.y,v.pos.z)
			local ms = Vector(1,1,1)
			if (!hasGarryFixedBoneScalingYet) then
				local cur = vm:GetBoneParent(bone)
				while(cur >= 0) do
					local pscale = loopthrough[vm:GetBoneName(cur)].scale
					ms = ms * pscale
					cur = vm:GetBoneParent(cur)
				end
			end
			
			s = s * ms
			// !! ----------- !! //
			
			if vm:GetManipulateBoneScale(bone) != s then
				vm:ManipulateBoneScale( bone, s )
			end
			if vm:GetManipulateBoneAngles(bone) != v.angle then
				vm:ManipulateBoneAngles( bone, v.angle )
			end
			if vm:GetManipulateBonePosition(bone) != p then
				vm:ManipulateBonePosition( bone, p )
			end
		end
	else
		self:ResetBonePositions(vm)
	end
	   
end
 
function SWEP:ResetBonePositions(vm)
	
	if (!vm:GetBoneCount()) then return end
	for i=0, vm:GetBoneCount() do
		vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
		vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
		vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
	end
	
end

--**************************
	--Global utility code--
--**************************/

-- Fully copies the table, meaning all tables inside this table are copied too and so on (normal table.Copy copies only their reference).
-- Does not copy entities of course, only copies their reference.
-- WARNING: do not use on tables that contain themselves somewhere down the line or you'll get an infinite loop
function table.FullCopy( tab )

	if (!tab) then return nil end
	
	local res = {}
	for k, v in pairs( tab ) do
		if (type(v) == "table") then
			res[k] = table.FullCopy(v) --recursion ho!
		elseif (type(v) == "Vector") then
			res[k] = Vector(v.x, v.y, v.z)
		elseif (type(v) == "Angle") then
			res[k] = Angle(v.p, v.y, v.r)
		else
			res[k] = v
		end
	end
	
	return res
	
end

end

– Weapon Code
if SERVER then --This is where the init.lua stuff goes.

--This makes sure clients download the file
AddCSLuaFile ("shared.lua")

--How heavy the SWep is
SWEP.Weight = 5

//Allow automatic switching to/from this weapon when weapons are picked up
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false

elseif CLIENT then // This is where the cl_init.lua stuff goes

//The name of the SWep, as appears in the weapons tab in the spawn menu(Q Menu)
SWEP.PrintName = "Person Launcher"

//Sets the position of the weapon in the switching menu 
//(appears when you use the scroll wheel or keys 1-6 by default)
SWEP.Slot = 3
SWEP.SlotPos = 1

//Sets drawing the ammuntion levels for this weapon
SWEP.DrawAmmo = true

//Sets the drawing of the crosshair when this weapon is deployed
SWEP.DrawCrosshair = false

//Ensures a clean looking notification when a chair is undone. How it works:
//When you create an undo, you specify the ID:
//		undo.Create("Some_Identity")
//By creating an associated language, we can make the undo notification look better:
//		language.Add("Undone_Some_Identity", "Some message...")

language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity")

end

SWEP.Author = “SinZNib”
SWEP.Contact = “”
SWEP.Purpose = “Launch People!”
SWEP.Instructions = “Left Click To Launch A Person! Right Click To Launch 5 People!”

//The category that you SWep will be shown in, in the Spawn (Q) Menu
//(This can be anything, GMod will create the categories for you)
SWEP.Category = “Noob’s Weapons”

SWEP.Spawnable = true – Whether regular players can see it
SWEP.AdminSpawnable = true – Whether Admins/Super Admins can see it

SWEP.ViewModel = “models/weapons/v_rpg.mdl” – This is the model used for clients to see in first person.
SWEP.WorldModel = “models/weapons/w_rocket_launcher.mdl” – This is the model shown to all other clients and in third-person.

//This determins how big each clip/magazine for the gun is. You can
//set it to -1 to disable the ammo system, meaning primary ammo will
//not be displayed and will not be affected.
SWEP.Primary.ClipSize = -1

//This sets the number of rounds in the clip when you first get the gun. Again it can be set to -1.
SWEP.Primary.DefaultClip = -1

//Obvious. Determines whether the primary fire is automatic. This should be true/false
SWEP.Primary.Automatic = false

//Sets the ammunition type the gun uses, see below for a list of types.
SWEP.Primary.Ammo = “true”

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

//When the script loads, the sound ‘‘Metal.SawbladeStick’’ will be precached,
//and a local variable with the sound name created.
local ShootSound = Sound(“Weapon_SMG1.Double”)

function SWEP:Reload()
end

function SWEP:Think()
end

function SWEP:throw_attack (model_file)
//Get an eye trace. This basically draws an invisible line from
//the players eye. This SWep makes very little use of the trace, except to
//calculate the amount of force to apply to the object thrown.
local tr = self.Owner:GetEyeTrace()

//Play some noises/effects using the sound we precached earlier
self:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)

//We now exit if this function is not running serverside
if (!SERVER) then return end

//The next task is to create a physics prop based on the supplied model
local ent = ents.Create("prop_physics")
ent:SetModel(model_file)

//Set the initial position and angles of the object. This might need some fine tuning;
//but it seems to work for the models I have tried.
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
ent:SetAngles(self.Owner:EyeAngles())
ent:Spawn()

//Now we need to get the physics object for our entity so we can apply a force to it
local phys = ent:GetPhysicsObject()

//Check if the physics object is valid. If not, remove the entity and stop the function
if !(phys && IsValid(phys)) then ent:Remove() return end

//Time to apply the force. My method for doing this was almost entirely empirical 
//and it seems to work fairly intuitively with chairs.
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() *  math.pow(tr.HitPos:Length(), 3))

//Now for the important part of adding the spawned objects to the undo and cleanup lists.
cleanup.Add(self.Owner, "props", ent)

undo.Create ("Ragdoll")
	undo.AddEntity (ent)
	undo.SetPlayer (self.Owner)
undo.Finish()

end

//Throw an office chair on primary attack
function SWEP:PrimaryAttack()
//Call the throw attack function, with the office chair model
self:throw_attack(“models/Humans/Group01/male_07.mdl”)
end

//Throw a wooden chair on secondary attack
function SWEP:SecondaryAttack()
//Call the throw attack function, this time with the wooden chair model
self:throw_attack(“models/Humans/Group01/male_07.mdl”)
self:throw_attack(“models/Humans/Group01/male_09.mdl”)
self:throw_attack(“models/Humans/Group01/male_08.mdl”)
self:throw_attack(“models/Humans/Group01/male_06.mdl”)
self:throw_attack(“models/Humans/Group01/male_05.mdl”)
end

was gonna add custom models but the code failed anyways, take a look!

Your mistake is here, you must use prop_ragdoll and not prop_physics.
Another thing, you could have copied and pasted only the requested function, it was far from difficult and it would have looked less “garbage” on your message… :sleepy:

yeah… but oh well

When editing my post yesterday I deleted the important part of the solution, sorry. It’s fine now!

ok.