Advertisement
KrYn0MoRe

glock (new gun system)

Nov 19th, 2020 (edited)
2,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 43.78 KB | None | 0 0
  1. local plr,char,hum,root
  2.  
  3. plr = owner
  4. char = plr.Character
  5. hum = char:FindFirstChildOfClass("Humanoid")
  6. root = char:FindFirstChild("HumanoidRootPart")
  7. head = char:FindFirstChild("Head")
  8.  
  9. Tool0 = Instance.new("Tool")
  10. Part1 = Instance.new("Part")
  11. SpecialMesh2 = Instance.new("SpecialMesh")
  12. Tool0.Name = "Glock"
  13. Tool0.Parent = nil
  14. Part1.Name = "Handle"
  15. Part1.Parent = Tool0
  16. Part1.CFrame = CFrame.new(-9.40400028, 0.49000001, -11.9640007, -1, 0, 8.74227766e-08, 0, 1, 0, -8.74227766e-08, 0, -1)
  17. Part1.Orientation = Vector3.new(0, 180, 0)
  18. Part1.Position = Vector3.new(-9.40400028, 0.49000001, -11.9640007)
  19. Part1.Rotation = Vector3.new(-180, 0, -180)
  20. Part1.Size = Vector3.new(1.44400001, 0.980000019, 0.231999993)
  21. Part1.Anchored = true
  22. Part1.BottomSurface = Enum.SurfaceType.Smooth
  23. Part1.CanCollide = false
  24. Part1.TopSurface = Enum.SurfaceType.Smooth
  25. SpecialMesh2.Parent = Part1
  26. SpecialMesh2.MeshId = "rbxassetid://543260475"
  27. SpecialMesh2.Scale = Vector3.new(0.0710000023, 0.0710000023, 0.0710000023)
  28. SpecialMesh2.TextureId = "rbxassetid://543261418"
  29. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  30.  
  31. local tool,handle
  32. tool = Tool0
  33. handle = tool:FindFirstChild("Handle")
  34.  
  35. for i,v in pairs(tool:GetChildren()) do
  36.     if v:IsA("BasePart") then
  37.         v.Anchored = false
  38.         v.CanCollide = false
  39.         v.Locked = true
  40.         if v ~= handle then
  41.             local weld = Instance.new("Weld")
  42.             weld.Part0 = handle
  43.             weld.Part1 = v
  44.             weld.C0 = handle.CFrame:Inverse()
  45.             weld.C1 = v.CFrame:Inverse()
  46.             weld.Parent = v
  47.         else
  48.             v.CanCollide = true
  49.         end
  50.     end
  51. end
  52.  
  53. tool.Parent = plr:FindFirstChildOfClass("Backpack")
  54.  
  55. local grips = {
  56.     shooting = CFrame.new(-0.335572511, -0.202204779, -0.00730848266, 1.17396892e-08, 0.17555213, -0.984470129, -2.09343809e-09, 0.984470129, 0.17555213, 1, 0, 1.19248806e-08),
  57.     equipped = CFrame.new(-0.331445694, -0.158765793, -0.00730848266, 1.19248806e-08, 0, -1, 0, 1, 0, 1, 0, 1.19248806e-08),
  58. }
  59.  
  60. tool.Grip = grips.equipped
  61.  
  62. local bulletfire = 3
  63. local shootwait = 0.2/bulletfire
  64. local max_tot_ammo = 1/0
  65. local tot_ammo = max_tot_ammo
  66. local max_ammo = 18
  67. local ammo = max_ammo
  68. local recoil = 0
  69. local using = false
  70. local equipped = false
  71. local op = false
  72. local hud = nil
  73. local remote = nil
  74. local junk = workspace:FindFirstChild("junk") or workspace
  75.  
  76. local bullettype = 1
  77. local bullettypes = {
  78.     [1] = { -- small (smgs, pistols)
  79.         mesh = 'http://www.roblox.com/asset/?id=95387759',
  80.         texture = 'http://www.roblox.com/asset/?id=95387789',
  81.         scale = Vector3.new(1.8, 1.8, 1.8),
  82.         size = Vector3.new(0.12, 0.12, 0.21)
  83.     },
  84.     [2] = { -- medium (rifles)
  85.         mesh = 'http://www.roblox.com/asset/?id=95392019',
  86.         texture = 'http://www.roblox.com/asset/?id=95391833',
  87.         scale = Vector3.new(0.9, 0.9, 0.9),
  88.         size = Vector3.new(0.12, 0.12, 0.192)
  89.     },
  90.     [3] = { -- big (snipers, big bois)
  91.         mesh = 'http://www.roblox.com/asset/?id=94295100',
  92.         texture = 'http://www.roblox.com/asset/?id=94287792',
  93.         scale = Vector3.new(2.4, 2.4, 2.4),
  94.         size = Vector3.new(0.12, 0.12, 0.372)
  95.     },
  96.     [4] = { -- medium (shotguns)
  97.         mesh = 'http://www.roblox.com/asset/?id=94248124',
  98.         texture = 'http://www.roblox.com/asset/?id=94219470',
  99.         scale = Vector3.new(0.45, 0.45, 0.45),
  100.         size = Vector3.new(0.12, 0.12, 0.234)
  101.     },
  102. }
  103.  
  104. local equip = Instance.new("Sound")
  105. equip.SoundId = 'rbxassetid://769464514'
  106. equip.Volume = 0.8
  107. equip.Parent = handle
  108.  
  109. local reload_s = Instance.new("Sound")
  110. reload_s.SoundId = 'rbxassetid://269172810'
  111. reload_s.Volume = 0.7
  112. reload_s.Parent = handle
  113.  
  114. local wbreak_s = Instance.new("Sound")
  115. wbreak_s.SoundId = "rbxassetid://627558611"
  116. wbreak_s.Volume = 0.7
  117. wbreak_s.Parent = handle
  118.  
  119. local empty_s = Instance.new("Sound")
  120. empty_s.SoundId = 'rbxassetid://132464034'
  121. empty_s.Volume = 0.7
  122. empty_s.Parent = handle
  123.  
  124. local shoots = {}
  125.  
  126. for i = 1,bulletfire do
  127.     local shoot_s = Instance.new("Sound")
  128.     shoot_s.Name = 'shoot'
  129.     shoot_s.SoundId = 'rbxassetid://240718012'
  130.     shoot_s.Volume = 2
  131.     shoot_s.Parent = handle
  132.     shoots['shoot' .. i] = shoot_s
  133. end
  134.  
  135. local effect_part = Instance.new("Part")
  136. local smoke = Instance.new("ParticleEmitter")
  137. local flash = Instance.new("ParticleEmitter")
  138. local light = Instance.new("PointLight")
  139. effect_part.Name = "effect"
  140. effect_part.Parent = tool
  141. effect_part.CFrame = CFrame.new(-14.3099976, 2.64201403, -6.57999992)
  142. effect_part.Transparency = 1
  143. effect_part.Size = Vector3.new(0.100000001, 0.100000001, 0.100000001)
  144. effect_part.BottomSurface = Enum.SurfaceType.Smooth
  145. effect_part.CanCollide = false
  146. effect_part.TopSurface = Enum.SurfaceType.Smooth
  147. smoke.Name = "smoke"
  148. smoke.Parent = effect_part
  149. smoke.Speed = NumberRange.new(5, 7)
  150. smoke.Rotation = NumberRange.new(0, 360)
  151. smoke.Color = ColorSequence.new(Color3.new(0.27451, 0.27451, 0.27451),Color3.new(0.27451, 0.27451, 0.27451))
  152. smoke.Enabled = false
  153. smoke.LightEmission = 0.10000000149012
  154. smoke.Texture = "http://www.roblox.com/asset/?id=244514423"
  155. smoke.Transparency = NumberSequence.new(0.60000002384186,1)
  156. smoke.Size = NumberSequence.new(0.99999964237213,3)
  157. smoke.Lifetime = NumberRange.new(1.25, 1.5)
  158. smoke.Rate = 100
  159. smoke.RotSpeed = NumberRange.new(10, 10)
  160. smoke.SpreadAngle = Vector2.new(15, 15)
  161. smoke.VelocitySpread = 15
  162. flash.Name = "flash"
  163. flash.Parent = effect_part
  164. flash.Speed = NumberRange.new(0, 0)
  165. flash.Rotation = NumberRange.new(0, 90)
  166. flash.Color = ColorSequence.new(Color3.new(1, 1, 0.498039),Color3.new(1, 1, 0.498039))
  167. flash.Enabled = false
  168. flash.LightEmission = 1
  169. flash.Texture = "http://www.roblox.com/asset/?id=3419963"
  170. flash.Transparency = NumberSequence.new(0.75,1)
  171. flash.Size = NumberSequence.new(0.20000000298023,0.20000000298023)
  172. flash.Lifetime = NumberRange.new(0.050000000745058, 0.075000002980232)
  173. flash.Speed = NumberRange.new(50,50)
  174. flash.Rate = 1000
  175. light.Name = "light"
  176. light.Parent = effect_part
  177. light.Color = Color3.new(1, 1, 0.498039)
  178. light.Enabled = false
  179. light.Range = 6
  180. light.Brightness = 10
  181. light.Shadows = true
  182.  
  183. local weld = Instance.new("Weld")
  184. weld.Part0 = handle
  185. weld.Part1 = effect_part
  186. weld.C0 = weld.C0 * CFrame.new((handle.Size.X/2),0.35,0) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(-90))
  187. weld.Parent = effect_part
  188.  
  189. function usefx()
  190.     spawn(function()
  191.         local mode = true
  192.         light.Enabled = mode
  193.         flash.Enabled = mode
  194.         smoke.Enabled = mode
  195.         wait()
  196.         mode = false
  197.         light.Enabled = mode
  198.         flash.Enabled = mode
  199.         smoke.Enabled = mode
  200.     end)
  201. end
  202.  
  203. function alive(c)
  204.     if c and c:FindFirstChildOfClass("Humanoid") and c:FindFirstChildOfClass("Humanoid").Health > 0 and (c:FindFirstChild("HumanoidRootPart") or c:FindFirstChild("Torso")) and c:FindFirstChild("Head") then
  205.         return true
  206.     end
  207.     return false
  208. end
  209.  
  210. function exists(c)
  211.     if c and c:FindFirstChildOfClass("Humanoid") and (c:FindFirstChild("HumanoidRootPart") or c:FindFirstChild("Torso")) and c:FindFirstChild("Head") then
  212.         return true
  213.     end
  214.     return false
  215. end
  216.  
  217. function reload()
  218.     if max_ammo > ammo then else return end
  219.     empty_s:Play()
  220.     if 0 >= tot_ammo then
  221.         return
  222.     end
  223.     using = true
  224.     reload_s:Play()
  225.     local mag = Instance.new("Part")
  226.     mag.Name = 'gun mag'
  227.     mag.Size = Vector3.new(0.48, 0.8, 0.14)
  228.     mag.Color = handle.Color
  229.     mag.Parent = junk
  230.     mag.CFrame = handle.CFrame * CFrame.new(0.1,-0.1,0)
  231.     --[[
  232.     local m = gun.Mag:Clone()
  233.     m.CanCollide = true
  234.     m:FindFirstChild("Weld"):Destroy()
  235.     m.Parent = junk
  236.     ]]
  237.     game:GetService("Debris"):AddItem(mag,10)
  238.     repeat wait() until not reload_s.IsPlaying --[[or not equipped]]
  239.     --[[
  240.     if not equipped then
  241.         using = false
  242.         reload_s:Stop()
  243.         return
  244.     end
  245.     ]]
  246.     if max_ammo >= tot_ammo then
  247.         ammo = ammo + tot_ammo
  248.         tot_ammo = 0
  249.         if ammo > max_ammo then
  250.             local reserve = ammo-max_ammo
  251.             ammo = ammo - reserve
  252.             tot_ammo = tot_ammo + reserve
  253.         end
  254.     elseif tot_ammo > max_ammo then
  255.         ammo = ammo + max_ammo
  256.         tot_ammo = tot_ammo - max_ammo
  257.         if ammo > max_ammo then
  258.             local reserve = ammo-max_ammo
  259.             ammo = ammo - reserve
  260.             tot_ammo = tot_ammo + reserve
  261.         end
  262.     end
  263.     if equipped then
  264.         if hud then
  265.             hud.ammo.Text = ammo .. '/' .. tot_ammo
  266.         end
  267.     end
  268.     using = false
  269. end
  270.  
  271. function drop_shell()
  272.     local Shell = Instance.new("Part")
  273.     Shell.Color = Color3.new(1, 1, 0)
  274.     Shell.BottomSurface = Enum.SurfaceType.Smooth
  275.     Shell.BrickColor = BrickColor.new("New Yeller")
  276.     Shell.Material = Enum.Material.Metal
  277.     Shell.Shape = Enum.PartType.Cylinder
  278.     Shell.CFrame = handle.CFrame
  279.     local bt = bullettypes[bullettype]
  280.     local mesh = Instance.new("SpecialMesh")
  281.     mesh.MeshId = bt.mesh
  282.     mesh.TextureId = bt.texture
  283.     mesh.Scale = bt.scale
  284.     mesh.Parent = Shell
  285.     Shell.Size = bt.size
  286.     Shell.Parent = junk
  287.     local bvs = Instance.new("BodyVelocity")
  288.     bvs.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  289.     bvs.Velocity = ((handle.CFrame.lookVector*-1)+Vector3.new(0,2,0))*5
  290.     bvs.Parent = Shell
  291.     game:GetService("Debris"):AddItem(bvs,0.1)
  292.     game:GetService("Debris"):AddItem(Shell,10)
  293. end
  294.  
  295. function raycast(Pos, Dir, Max, Ignore)
  296.     local rayparams = RaycastParams.new()
  297.     rayparams.FilterType = Enum.RaycastFilterType.Blacklist
  298.     rayparams.FilterDescendantsInstances = Ignore
  299.     rayparams.IgnoreWater = true
  300.     return workspace:Raycast(Pos, Dir * (Max or 999.999), rayparams)
  301. end
  302.  
  303. function bullet_trail(mousepos)
  304.     spawn(function()
  305.         local s = 0.1
  306.         local p = Instance.new("Part")
  307.         p.Name = "bullet"
  308.         p.Anchored = false
  309.         p.CanCollide = false
  310.         p.Size = Vector3.new(s,s,s)
  311.         p.Transparency = 1
  312.         p.Position = handle.Position
  313.         local at1,at2 = Instance.new("Attachment"),Instance.new("Attachment")
  314.         at1.Position = Vector3.new(-s/2,0,0)
  315.         at2.Position = Vector3.new(s/2,0,0)
  316.         at1.Parent = p
  317.         at2.Parent = p
  318.         local trail = Instance.new("Trail")
  319.         trail.Attachment0 = at1
  320.         trail.Attachment1 = at2
  321.         trail.FaceCamera = true
  322.         trail.Transparency = NumberSequence.new(0,1)
  323.         trail.Lifetime = 0.5
  324.         trail.MaxLength = 1/0
  325.         trail.MinLength = 0
  326.         trail.Parent = p
  327.         p.Parent = junk
  328.         p:SetNetworkOwner(plr)
  329.         wait()
  330.         local body_vel = Instance.new("BodyVelocity")
  331.         body_vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  332.         body_vel.Velocity = (mousepos-handle.Position).Unit * 2500
  333.         body_vel.Parent = p
  334.         game:GetService("Debris"):AddItem(p,3)
  335.     end)
  336. end
  337.  
  338. local blood_images = {931617584,1663434319,1391189545,4533673847,3236192667,2565888666,612591729,120362139,116830967,122022304,131339257,247766282,121678640,176677800,120361912,176678070,176678086,176677869} --305296807,256293532,148713503,176678030
  339.  
  340. local e_s = 1
  341.  
  342. function add_decal(f,t,obj)
  343.     --spawn(function()
  344.     if obj:FindFirstChild("blood" .. f) then return end
  345.     local texture = Instance.new("Texture")
  346.     texture.Name = ('blood' .. f)
  347.     texture.Parent = obj
  348.     texture.Face = f
  349.     texture.Texture = 'rbxassetid://' .. t
  350.     game:GetService("Debris"):AddItem(texture,10)
  351.     if f == 'Left' or f == 'Right' then
  352.         texture.StudsPerTileV = obj.Size.Y + e_s
  353.         if (obj.Size.X > obj.Size.Z) then
  354.             texture.StudsPerTileV = obj.Size.Z + e_s
  355.         elseif (obj.Size.Z > obj.Size.X) then
  356.             texture.StudsPerTileU = obj.Size.X + e_s
  357.         else
  358.             texture.StudsPerTileU = obj.Size.X + e_s
  359.         end
  360.     elseif f == 'Front' or f == 'Back' then
  361.         texture.StudsPerTileV = obj.Size.Y + e_s
  362.         if (obj.Size.X > obj.Size.Z) then
  363.             texture.StudsPerTileV = obj.Size.X + e_s
  364.         elseif (obj.Size.Z > obj.Size.X) then
  365.             texture.StudsPerTileU = obj.Size.Z + e_s
  366.         else
  367.             texture.StudsPerTileU = obj.Size.X + e_s
  368.         end
  369.     elseif f == 'Top' or f == 'Bottom' then
  370.         texture.StudsPerTileV = obj.Size.X + e_s
  371.         texture.StudsPerTileU = obj.Size.Z + e_s
  372.     end
  373.     --end)
  374. end
  375.  
  376. function add_blood(obj)
  377.     local t1,t2,t3,t4,t5,t6 = blood_images[math.random(1,#blood_images)],blood_images[math.random(1,#blood_images)],blood_images[math.random(1,#blood_images)],blood_images[math.random(1,#blood_images)],blood_images[math.random(1,#blood_images)],blood_images[math.random(1,#blood_images)]
  378.     add_decal('Top',t1,obj)
  379.     add_decal('Bottom',t2,obj)
  380.     add_decal('Left',t3,obj)
  381.     add_decal('Right',t4,obj)
  382.     add_decal('Front',t5,obj)
  383.     add_decal('Back',t6,obj)
  384. end
  385.  
  386. function break_window(hit)
  387.     if hit.Material == Enum.Material.Glass --[[hit.Name == 'window']] and hit.Name ~= 'window shatter' and hit.Name ~= 'blood' and hit.Name ~= 'blood_drop' then else return end
  388.     hit.Name = ''
  389.     local wbreak = wbreak_s:Clone()
  390.     wbreak.Parent = hit
  391.     wbreak:Play()
  392.     local sx,sy,sz = hit.Size.x,hit.Size.y,hit.Size.z
  393.     for x = 1,4 do
  394.         for y = 1,4 do
  395.             local part = hit:Clone()
  396.             local position = Vector3.new(x-2.1,y-2.1,0)*Vector3.new(sx/4,sy/4,sz)
  397.             part.Size = Vector3.new(sx/4,sy/4,sz)
  398.             part.CFrame = hit.CFrame*(CFrame.new(part.Size/8)-hit.Size/8+position)         
  399.             part.Velocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
  400.             part.Name = "window shatter"
  401.             part.Parent = hit.Parent
  402.             game:GetService("Debris"):AddItem(part,2)
  403.             spawn(function()
  404.                 wait(0.5)
  405.                 for i = 1,10 do
  406.                     part.Transparency = part.Transparency+0.05
  407.                     wait(0.05)
  408.                 end
  409.                 part:Destroy()
  410.             end)
  411.             part.Anchored = false
  412.         end
  413.     end
  414.     hit:Destroy()
  415. end
  416.  
  417. function make_bone(obj,targtorso)
  418.     if obj.Name == 'Left Arm' or obj.Name == 'LeftUpperArm' then
  419.         local bone = Instance.new("Part")
  420.         bone.Name = 'bone'
  421.         bone.CanCollide = false
  422.         bone.Anchored = false
  423.         bone.CFrame = targtorso.CFrame
  424.         bone.Size = targtorso.Size
  425.         bone.Massless = true
  426.         bone.Locked = true
  427.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  428.         if not exists then
  429.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  430.         end
  431.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  432.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  433.         game:GetService("PhysicsService"):SetPartCollisionGroup(targtorso,'Limb Collide')
  434.         local weld = Instance.new("Weld")
  435.         weld.Part0 = bone
  436.         weld.Part1 = targtorso
  437.         weld.C1 = CFrame.new(-0.61,0.77,0.03)*CFrame.Angles(math.rad(90),0,math.rad(90))
  438.         weld.Parent = bone
  439.         targtorso.Anchored = false
  440.         bone.Parent = junk
  441.         local mesh = Instance.new("SpecialMesh")
  442.         mesh.MeshId = 'rbxassetid://1076136382'
  443.         mesh.TextureId = 'rbxassetid://1076137938'
  444.         mesh.Scale = Vector3.new(0.03,0.03,0.03)
  445.         mesh.Parent = bone
  446.         --
  447.         local bone = Instance.new("Part")
  448.         bone.Name = 'bone'
  449.         bone.CanCollide = false
  450.         bone.Anchored = false
  451.         bone.CFrame = obj.CFrame
  452.         bone.Size = obj.Size
  453.         bone.Massless = true
  454.         bone.Locked = true
  455.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  456.         if not exists then
  457.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  458.         end
  459.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  460.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  461.         game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  462.         local weld = Instance.new("Weld")
  463.         weld.Part0 = bone
  464.         weld.Part1 = obj
  465.         weld.C1 = CFrame.new(0.13,0.26,0)
  466.         weld.Parent = bone
  467.         obj.Anchored = false
  468.         bone.Parent = junk
  469.         local mesh = Instance.new("SpecialMesh")
  470.         mesh.MeshId = 'rbxassetid://36780032'
  471.         mesh.TextureId = 'rbxassetid://36780292'
  472.         mesh.Parent = bone
  473.     elseif obj.Name == 'Right Arm' or obj.Name == 'RightUpperArm' then
  474.         local bone = Instance.new("Part")
  475.         bone.Name = 'bone'
  476.         bone.CanCollide = false
  477.         bone.Anchored = false
  478.         bone.CFrame = targtorso.CFrame
  479.         bone.Size = targtorso.Size
  480.         bone.Massless = true
  481.         bone.Locked = true
  482.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  483.         if not exists then
  484.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  485.         end
  486.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  487.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  488.         game:GetService("PhysicsService"):SetPartCollisionGroup(targtorso,'Limb Collide')
  489.         local weld = Instance.new("Weld")
  490.         weld.Part0 = bone
  491.         weld.Part1 = targtorso
  492.         weld.C1 = CFrame.new(0.61,0.77,0.03)*CFrame.Angles(math.rad(90),0,math.rad(-90))
  493.         weld.Parent = bone
  494.         targtorso.Anchored = false
  495.         bone.Parent = junk
  496.         local mesh = Instance.new("SpecialMesh")
  497.         mesh.MeshId = 'rbxassetid://1076136382'
  498.         mesh.TextureId = 'rbxassetid://1076137938'
  499.         mesh.Scale = Vector3.new(0.03,0.03,0.03)
  500.         mesh.Parent = bone
  501.         --
  502.         local bone = Instance.new("Part")
  503.         bone.Name = 'bone'
  504.         bone.CanCollide = false
  505.         bone.Anchored = false
  506.         bone.CFrame = obj.CFrame
  507.         bone.Size = obj.Size
  508.         bone.Massless = true
  509.         bone.Locked = true
  510.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  511.         if not exists then
  512.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  513.         end
  514.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  515.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  516.         game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  517.         local weld = Instance.new("Weld")
  518.         weld.Part0 = bone
  519.         weld.Part1 = obj
  520.         weld.C1 = CFrame.new(-0.13,0.26,0)
  521.         weld.Parent = bone
  522.         obj.Anchored = false
  523.         bone.Parent = junk
  524.         local mesh = Instance.new("SpecialMesh")
  525.         mesh.MeshId = 'rbxassetid://36780156'
  526.         mesh.TextureId = 'rbxassetid://36780292'
  527.         mesh.Parent = bone
  528.     elseif obj.Name == 'Left Leg' or obj.Name == 'LeftUpperLeg' then
  529.         local bone = Instance.new("Part")
  530.         bone.Name = 'bone'
  531.         bone.CanCollide = false
  532.         bone.Anchored = false
  533.         bone.CFrame = targtorso.CFrame
  534.         bone.Size = targtorso.Size
  535.         bone.Massless = true
  536.         bone.Locked = true
  537.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  538.         if not exists then
  539.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  540.         end
  541.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  542.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  543.         game:GetService("PhysicsService"):SetPartCollisionGroup(targtorso,'Limb Collide')
  544.         local weld = Instance.new("Weld")
  545.         weld.Part0 = bone
  546.         weld.Part1 = targtorso
  547.         weld.C1 = CFrame.new(-0.6,-0.64,0.11)*CFrame.Angles(0,0,math.rad(180))
  548.         weld.Parent = bone
  549.         targtorso.Anchored = false
  550.         bone.Parent = junk
  551.         local mesh = Instance.new("SpecialMesh")
  552.         mesh.MeshId = 'rbxassetid://1076136382'
  553.         mesh.TextureId = 'rbxassetid://1076137938'
  554.         mesh.Scale = Vector3.new(0.03,0.03,0.03)
  555.         mesh.Parent = bone
  556.         --
  557.         local bone = Instance.new("Part")
  558.         bone.Name = 'bone'
  559.         bone.CanCollide = false
  560.         bone.Anchored = false
  561.         bone.CFrame = obj.CFrame
  562.         bone.Size = obj.Size
  563.         bone.Massless = true
  564.         bone.Locked = true
  565.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  566.         if not exists then
  567.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  568.         end
  569.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  570.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  571.         game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  572.         local weld = Instance.new("Weld")
  573.         weld.Part0 = bone
  574.         weld.Part1 = obj
  575.         weld.C1 = CFrame.new(0,0.09,0.13)
  576.         weld.Parent = bone
  577.         obj.Anchored = false
  578.         bone.Parent = junk
  579.         local mesh = Instance.new("SpecialMesh")
  580.         mesh.MeshId = 'rbxassetid://36780156'
  581.         mesh.TextureId = 'rbxassetid://36780292'
  582.         mesh.Parent = bone
  583.     elseif obj.Name == 'Right Leg' or obj.Name == 'RightUpperLeg' then
  584.         local bone = Instance.new("Part")
  585.         bone.Name = 'bone'
  586.         bone.CanCollide = false
  587.         bone.Anchored = false
  588.         bone.CFrame = targtorso.CFrame
  589.         bone.Size = targtorso.Size
  590.         bone.Massless = true
  591.         bone.Locked = true
  592.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  593.         if not exists then
  594.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  595.         end
  596.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  597.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  598.         game:GetService("PhysicsService"):SetPartCollisionGroup(targtorso,'Limb Collide')
  599.         local weld = Instance.new("Weld")
  600.         weld.Part0 = bone
  601.         weld.Part1 = targtorso
  602.         weld.C1 = CFrame.new(0.6,-0.64,0.11)*CFrame.Angles(0,0,math.rad(180))
  603.         weld.Parent = bone
  604.         targtorso.Anchored = false
  605.         bone.Parent = junk
  606.         local mesh = Instance.new("SpecialMesh")
  607.         mesh.MeshId = 'rbxassetid://1076136382'
  608.         mesh.TextureId = 'rbxassetid://1076137938'
  609.         mesh.Scale = Vector3.new(0.03,0.03,0.03)
  610.         mesh.Parent = bone
  611.         --
  612.         local bone = Instance.new("Part")
  613.         bone.Name = 'bone'
  614.         bone.CanCollide = false
  615.         bone.Anchored = false
  616.         bone.CFrame = obj.CFrame
  617.         bone.Size = obj.Size
  618.         bone.Massless = true
  619.         bone.Locked = true
  620.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  621.         if not exists then
  622.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  623.         end
  624.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  625.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  626.         game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  627.         local weld = Instance.new("Weld")
  628.         weld.Part0 = bone
  629.         weld.Part1 = obj
  630.         weld.C1 = CFrame.new(0,0.09,0.13)
  631.         weld.Parent = bone
  632.         obj.Anchored = false
  633.         bone.Parent = junk
  634.         local mesh = Instance.new("SpecialMesh")
  635.         mesh.MeshId = 'rbxassetid://36780195'
  636.         mesh.TextureId = 'rbxassetid://36780292'
  637.         mesh.Parent = bone
  638.     elseif obj.Name == 'Head' then
  639.         local bone = Instance.new("Part")
  640.         bone.Name = 'bone'
  641.         bone.CanCollide = false
  642.         bone.Anchored = false
  643.         bone.CFrame = targtorso.CFrame
  644.         bone.Size = targtorso.Size
  645.         bone.Massless = true
  646.         bone.Locked = true
  647.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  648.         if not exists then
  649.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  650.         end
  651.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  652.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  653.         game:GetService("PhysicsService"):SetPartCollisionGroup(targtorso,'Limb Collide')
  654.         local weld = Instance.new("Weld")
  655.         weld.Part0 = bone
  656.         weld.Part1 = targtorso
  657.         weld.C1 = CFrame.new(0,0.66,0)
  658.         weld.Parent = bone
  659.         targtorso.Anchored = false
  660.         bone.Parent = junk
  661.         local mesh = Instance.new("SpecialMesh")
  662.         mesh.MeshId = 'rbxassetid://1076136382'
  663.         mesh.TextureId = 'rbxassetid://1076137938'
  664.         mesh.Scale = Vector3.new(0.03,0.03,0.03)
  665.         mesh.Parent = bone
  666.         --
  667.         local bone = Instance.new("Part")
  668.         bone.Name = 'bone'
  669.         bone.CanCollide = false
  670.         bone.Anchored = false
  671.         bone.CFrame = obj.CFrame
  672.         bone.Size = obj.Size
  673.         bone.Massless = true
  674.         bone.Locked = true
  675.         local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  676.         if not exists then
  677.             game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  678.         end
  679.         game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  680.         game:GetService("PhysicsService"):SetPartCollisionGroup(bone,'Limb Collide')
  681.         game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  682.         local weld = Instance.new("Weld")
  683.         weld.Part0 = bone
  684.         weld.Part1 = obj
  685.         weld.C1 = CFrame.new(0,-0.23,0)*CFrame.Angles(0,math.rad(-90),0)
  686.         weld.Parent = bone
  687.         obj.Anchored = false
  688.         bone.Parent = junk
  689.         local mesh = Instance.new("SpecialMesh")
  690.         mesh.MeshId = 'rbxassetid://1076136382'
  691.         mesh.TextureId = 'rbxassetid://1076137938'
  692.         mesh.Scale = Vector3.new(0.03,0.03,0.03)
  693.         mesh.Parent = bone
  694.     end
  695. end
  696.  
  697. function limb_collide(obj,mode,d)
  698.     if (obj:IsA("UnionOperation") or obj:IsA("BasePart")) and not obj:FindFirstChild('limb') then else return end
  699.     local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  700.     if not exists then
  701.         game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  702.     end
  703.     game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  704.     --
  705.     local t = {}
  706.     --
  707.     local cb = Instance.new("Part")
  708.     cb.Name = 'limb'
  709.     cb.Transparency = 1
  710.     cb.CanCollide = true
  711.     cb.Anchored = false
  712.     cb.CFrame = obj.CFrame
  713.     cb.Size = obj.Size
  714.     cb.Massless = true
  715.     cb.Locked = true
  716.     game:GetService("PhysicsService"):SetPartCollisionGroup(cb,'Limb Collide')
  717.     game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  718.     local weld = Instance.new("Weld")
  719.     weld.Part0 = cb
  720.     weld.Part1 = obj
  721.     weld.Parent = cb
  722.     obj.Massless = true
  723.     obj.Anchored = false
  724.     if mode or obj:FindFirstChild("Dismembered") then
  725.         cb.Parent = junk -- .Parent
  726.     else
  727.         cb.Parent = junk
  728.         table.insert(t,1,cb)
  729.     end
  730.     if d then
  731.         game:GetService("Debris"):AddItem(cb,d)
  732.     end
  733.     --
  734.     if not string.match(obj.Name:lower(),'torso') and not string.match(obj.Name:lower(),'rootpart') and not string.match(obj.Name:lower(),'head') then
  735.         local lv = Vector3.new() -- Vector3.new(cb.Size.X,0,cb.Size.Z)
  736.         local cb2 = Instance.new("Part")
  737.         cb2.Name = 'limb'
  738.         cb2.Transparency = 1
  739.         cb2.CanCollide = true
  740.         cb2.Anchored = false
  741.         cb2.CFrame = obj.CFrame
  742.         cb2.Size = lv
  743.         cb2.Massless = true
  744.         cb2.Locked = true
  745.         --game:GetService("PhysicsService"):SetPartCollisionGroup(cb2,'Limb Collide')
  746.         local weld2 = Instance.new("Weld")
  747.         weld2.Part0 = cb
  748.         weld2.Part1 = cb2
  749.         weld2.C1 = CFrame.new(0,(cb.Size.Y/2),0)
  750.         weld2.Parent = cb2
  751.         if mode or obj:FindFirstChild("Dismembered") then
  752.             cb2.Parent = junk -- .Parent
  753.         else
  754.             cb2.Parent = junk
  755.             table.insert(t,1,cb2)
  756.         end
  757.         if d then
  758.             game:GetService("Debris"):AddItem(cb2,d)
  759.         end
  760.     end
  761.     --
  762.     return t
  763. end
  764.  
  765. function kill(targchar,dir,kb)
  766.     local targhum = targchar:FindFirstChildOfClass("Humanoid")
  767.     local targtorso = targchar:FindFirstChild("Torso") or targchar:FindFirstChild("UpperTorso") or targchar:FindFirstChild("HumanoidRootPart")
  768.     if not targhum:FindFirstChild("killer") then else return end
  769.     local kval = Instance.new("ObjectValue")
  770.     kval.Name = 'killer'
  771.     kval.Parent = targhum
  772.     local bv = Instance.new("BodyVelocity")
  773.     bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  774.     bv.Velocity = dir*kb+Vector3.new(0,kb,0)
  775.     bv.Parent = targtorso
  776.     game:GetService("Debris"):AddItem(bv,0.1)
  777.     pcall(function()
  778.         ragdoll(targchar,true)
  779.     end)
  780. end
  781.  
  782. function bleed2(frick,targhum,can_hurt,t,splat,dir)
  783.     spawn(function()
  784.         if frick and targhum then else return end
  785.         --[[
  786.         if not frick:FindFirstChild("bleeding from kry's " .. tool.Name) then else return end
  787.         local tempbleedval = Instance.new("ObjectValue")
  788.         tempbleedval.Name = "bleeding from kry's " .. tool.Name
  789.         tempbleedval.Parent = frick
  790.         ]]
  791.         local bleeding = true
  792.         local rig = targhum.RigType
  793.         local limbs = {'Head','Left Arm','Right Arm','Left Leg','Right Leg','RightUpperLeg','LeftUpperLeg','RightUpperArm','LeftUpperArm','RightLowerLeg','LeftLowerLeg','RightLowerArm','LeftLowerArm','RightFoot','LeftFoot','RightHand','LeftHand'}
  794.         spawn(function()
  795.             wait(t)
  796.             bleeding = false
  797.             --tempbleedval:Destroy()
  798.         end)
  799.         while bleeding do
  800.             if (not frick or not frick.Parent or not frick.Parent.Parent or not targhum or not targhum.Parent) then
  801.                 break
  802.             end
  803.             local max_limbs = 0
  804.             local current_limbs = 0
  805.             local gone_limbs = 0
  806.             local targchar = targhum.Parent
  807.             if rig == Enum.HumanoidRigType.R6 then
  808.                 max_limbs = 5
  809.             elseif rig == Enum.HumanoidRigType.R15 then
  810.                 max_limbs = 13
  811.             end
  812.             for i,v in pairs(targchar:GetChildren()) do
  813.                 local found = false
  814.                 for i,n in pairs(limbs) do if n == v.Name then found = true; end; end;
  815.                 if found and not v:FindFirstChild("Dismembered") then
  816.                     current_limbs = current_limbs + 1
  817.                 end
  818.             end
  819.             gone_limbs = (max_limbs-current_limbs)
  820.             if targhum and can_hurt then
  821.                 if gone_limbs >= 1 then
  822.                     if 0 >= (targhum.Health - 0.2*gone_limbs) then
  823.                         targhum.BreakJointsOnDeath = false
  824.                     end
  825.                     targhum:TakeDamage(0.2*gone_limbs)
  826.                 else
  827.                     if 0 >= (targhum.Health - 0.2) then
  828.                         targhum.BreakJointsOnDeath = false
  829.                     end
  830.                     targhum:TakeDamage(0.2)
  831.                 end
  832.                 if 0 >= targhum.Health then
  833.                     kill(targchar,dir,5)
  834.                 end
  835.             end
  836.             spawn(function()
  837.                 local thing = Instance.new('Part')
  838.                 thing.Name = "blood_drop"
  839.                 thing:SetNetworkOwner(plr)
  840.                 thing.Size = Vector3.new(0.1,0.1,0.1)
  841.                 thing.CFrame = frick.CFrame*CFrame.new(0,frick.Size.Y/2,0)
  842.                 if splat then
  843.                     thing.Transparency = 0
  844.                 elseif not splat then
  845.                     thing.Transparency = 1
  846.                 end
  847.                 thing.Color = Color3.fromRGB(75, 0, 0)
  848.                 thing.Material = Enum.Material.SmoothPlastic
  849.                 thing.CanCollide = false
  850.                 thing.Parent = junk
  851.                 local mesh = Instance.new('SpecialMesh')
  852.                 mesh.MeshType = Enum.MeshType.Sphere
  853.                 mesh.Parent = thing
  854.                 --game:GetService("Debris"):AddItem(thing,5)
  855.                 local att1,att2 = Instance.new("Attachment"),Instance.new("Attachment")
  856.                 att1.Parent = thing
  857.                 att1.Position = Vector3.new(0,-(thing.Size.Y/2),0)
  858.                 att2.Parent = thing
  859.                 att2.Position = Vector3.new(0,(thing.Size.Y/2),0)
  860.                 if splat then
  861.                     local trail_drop = Instance.new("Trail")
  862.                     trail_drop.Parent = thing
  863.                     trail_drop.Attachment0 = att1
  864.                     trail_drop.Attachment1 = att2
  865.                     trail_drop.Color = ColorSequence.new(Color3.new(0.5, 0, 0),Color3.new(0.7, 0, 0))
  866.                     trail_drop.FaceCamera = true
  867.                     trail_drop.LightInfluence = 1
  868.                     trail_drop.WidthScale = NumberSequence.new(1,0)
  869.                     trail_drop.Transparency = NumberSequence.new(0,1)
  870.                     trail_drop.Lifetime = 0.1
  871.                     trail_drop.MinLength = 0
  872.                 end
  873.                 local rawrxd = Instance.new('BodyForce')
  874.                 rawrxd.Parent = thing
  875.                 rawrxd.Force = (dir*0.5)+Vector3.new(math.random(-5, 5)/40,math.random(-5, 5)/30,math.random(-5, 5)/40)
  876.                 game:GetService("Debris"):AddItem(rawrxd,0.01)
  877.                 thing.Touched:connect(function(tou)
  878.                     if tou and tou.Parent and not tou:IsDescendantOf(targchar) and not tou.Parent:FindFirstChildOfClass("Humanoid") and not tou.Parent.Parent:FindFirstChildOfClass("Humanoid") and not tou.Parent:IsA("Accessory") and tou.Name ~= 'Handle' and tou.Parent.Name ~= 'Handle' and not tou.Parent:IsA("Tool") and not string.match(tou.Name:lower(),'blood_drop') and not string.match(tou.Name:lower(),'bullet') and not string.match(tou.Name:lower(),'bone') and not string.match(tou.Name:lower(),'gun mag') and not string.match(tou.Name:lower(),'limb') then
  879.                         local pos = Vector3.new(thing.Position.X,(tou.Position.Y+(tou.Size.Y/2))+(0.02/2),thing.Position.Z)
  880.                         local Point1 = pos-Vector3.new(0.01,0.01,0.01)
  881.                         local Point2 = pos+Vector3.new(0.01,0.01,0.01)
  882.                         local Region = Region3.new(Point1,Point2)
  883.                         for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,math.huge)) do
  884.                             if Part.Name == "blood" then
  885.                                 tou = Part
  886.                             end
  887.                         end
  888.                         thing:Destroy()
  889.                         if tou.Name == "blood" then
  890.                             local reee = tou.CFrame
  891.                             if tou.Transparency > -0.2 then
  892.                                 tou.Transparency = tou.Transparency - 0.1
  893.                             end
  894.                             local s = 0.025
  895.                             if tou.Color.R > 0 then
  896.                                 local nc = tou.Color.R*1.012
  897.                                 if nc > 1 then
  898.                                     nc = 1
  899.                                 end
  900.                                 tou.Color = Color3.new(nc, 0, 0)
  901.                             end
  902.                             if tou.Size.X < 5 then
  903.                                 tou.Size = tou.Size+Vector3.new(s*4,0,s*4)
  904.                             elseif tou.Size.X < 7.5 then
  905.                                 tou.Size = tou.Size+Vector3.new(s*3,0,s*3)
  906.                             elseif tou.Size.X < 10 then
  907.                                 tou.Size = tou.Size+Vector3.new(s*2,0,s*2)
  908.                             end
  909.                             tou.CFrame = reee
  910.                             local tween = game:GetService("TweenService"):Create(tou,TweenInfo.new(4),{Transparency = 1})
  911.                             tween:Play()
  912.                             tween.Completed:Connect(function()
  913.                                 if tou.Transparency >= 0.9 then
  914.                                     tou:Destroy()
  915.                                 end
  916.                             end)
  917.                         elseif tou.CanCollide == true then
  918.                             local bloodsplat = Instance.new('Part')
  919.                             local s = math.random(5,10)/10
  920.                             if gone_limbs >= 1 then
  921.                                 bloodsplat.Size = Vector3.new(s*gone_limbs,0.2,s*gone_limbs)
  922.                             else
  923.                                 bloodsplat.Size = Vector3.new(s,0.2,s)
  924.                             end
  925.                             bloodsplat.Name = "blood"
  926.                             bloodsplat.Anchored = true
  927.                             bloodsplat.CanCollide = false
  928.                             bloodsplat.Material = Enum.Material.Glass
  929.                             bloodsplat.Color = Color3.fromRGB(75, 0, 0)
  930.                             bloodsplat.Transparency = -0.2
  931.                             bloodsplat.Parent = junk
  932.                             bloodsplat.CFrame = CFrame.new(pos)
  933.                             local mesh = Instance.new('SpecialMesh')
  934.                             mesh.MeshType = Enum.MeshType.Sphere
  935.                             mesh.Parent = bloodsplat
  936.                             local tween = game:GetService("TweenService"):Create(bloodsplat,TweenInfo.new(4),{Transparency = 1})
  937.                             tween:Play()
  938.                             tween.Completed:Connect(function()
  939.                                 if bloodsplat.Transparency >= 0.9 then
  940.                                     bloodsplat:Destroy()
  941.                                 end
  942.                             end)
  943.                         end
  944.                     end
  945.                 end)
  946.             end)
  947.             wait(0.1)
  948.         end
  949.     end)
  950. end
  951.  
  952. function break_limb(obj,targchar,dir)
  953.     local targhum = targchar:FindFirstChildOfClass("Humanoid")
  954.     local targtorso = targchar:FindFirstChild("Torso") or targchar:FindFirstChild("UpperTorso") or targchar:FindFirstChild("HumanoidRootPart")
  955.     if not obj:FindFirstChild('Dismembered') and obj.Name ~= 'Torso' and obj.Name ~= 'HumanoidRootPart' and obj.Name ~= 'UpperTorso' and obj.Name ~= 'LowerTorso' then else return end
  956.     local confirm = Instance.new("ObjectValue")
  957.     confirm.Name = 'Dismembered'
  958.     confirm.Parent = obj
  959.     local bsc = obj:FindFirstChildOfClass("BallSocketConstraint")
  960.     if bsc then
  961.         bsc:Destroy()
  962.     end
  963.     --bleed2(obj,targhum,true,10,true,dir)
  964.     --bleed2(targtorso,targhum,false,10,false,Vector3.new(0,-1,0).Unit)
  965.     local targchar = targhum.Parent
  966.     make_bone(obj,targtorso)
  967.     local kb = 15
  968.     local bv = Instance.new("BodyVelocity")
  969.     bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  970.     bv.Velocity = handle.CFrame.rightVector*kb+Vector3.new(0,kb,0)
  971.     bv.Parent = obj
  972.     game:GetService("Debris"):AddItem(bv,0.1)
  973.     local bsc = obj:FindFirstChildOfClass("BallSocketConstraint")
  974.     if bsc then
  975.         bsc:Destroy()
  976.     end
  977.     for _,m in pairs(targchar:GetChildren()) do
  978.         for _,v in pairs(m:GetChildren()) do
  979.             if (v:IsA('Motor6D') or v:IsA('Motor') or v:IsA('Snap') or v:IsA('Weld')) and (v.Part0 == obj or v.Part1 == obj) then
  980.                 v:Destroy()
  981.                 if string.match(obj.Name:lower(),'leg') then
  982.                     targhum.WalkSpeed = targhum.WalkSpeed/1.3
  983.                 end
  984.             end
  985.         end
  986.     end
  987.     limb_collide(obj,1,10)
  988.     obj.Massless = true
  989.     obj.CanCollide = false
  990.     obj.Anchored = false
  991.     game:GetService("Debris"):AddItem(obj,10)
  992. end
  993.  
  994. function ragdoll(targchar,kill,remove)
  995.     local targplr
  996.     pcall(function()
  997.         targplr = game:GetService("Players"):GetPlayerFromCharacter(targchar)
  998.     end)
  999.     local pc = targchar
  1000.     local targhum = pc:FindFirstChild("Humanoid")
  1001.     local js,js2 = {},{}
  1002.  
  1003.     if kill then
  1004.         local old_pc
  1005.         if remove then
  1006.             pc.Archivable = true
  1007.             old_pc = pc
  1008.             pc = pc:Clone()
  1009.         end
  1010.         for i,v in pairs(pc:GetDescendants()) do
  1011.             if v.Name ~= 'HumanoidRootPart' and v.Name ~= 'Torso' and v:IsA("BasePart") then
  1012.                 if remove then
  1013.                     limb_collide(v,true,10)
  1014.                 end
  1015.             end
  1016.             if v:IsA("ParticleEmitter") then
  1017.                 v.Enabled = false
  1018.             end
  1019.             if v:IsA("SelectionBox") or v:IsA("BodyVelocity") or v:IsA("BodyPosition") or v:IsA("BodyAngularVelocity") or v:IsA("BodyForce") or v:IsA("BodyGyro") or v:IsA("BodyThrust") or v:IsA("BodyMover") then
  1020.                 if v:IsA("BodyVelocity") then
  1021.                     game:GetService("Debris"):AddItem(v,0.15)
  1022.                 else
  1023.                     v:Destroy()
  1024.                 end
  1025.             end
  1026.             if (v:IsA("Script") and v.Name == 'Health') or (v:IsA("LocalScript") and v.Name == 'Animate') then
  1027.                 v:Destroy()
  1028.             end
  1029.             if v:IsA("Humanoid") then
  1030.                 v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
  1031.                 v.PlatformStand = true
  1032.             end
  1033.         end
  1034.         if remove then
  1035.             for i,v in pairs(old_pc:GetDescendants()) do
  1036.                 if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("ForceField") or v:IsA("Accessory") or v:IsA("Decal") or v:IsA("Texture") or v:IsA("SurfaceGui") then
  1037.                     v:destroy()
  1038.                 end
  1039.                 if v:IsA("Humanoid") then
  1040.                     v.BreakJointsOnDeath = true
  1041.                     v.Health = 0
  1042.                     v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
  1043.                     v.PlatformStand = true
  1044.                 end
  1045.             end
  1046.             pc.Parent = junk
  1047.             game:GetService("Debris"):AddItem(pc,10)
  1048.         end
  1049.     end
  1050.     if kill and targhum:FindFirstChild("Ragdolled") then return; end;
  1051.     coroutine.resume(coroutine.create(function()
  1052.         if targplr then
  1053.             for i,v in pairs(pc:GetChildren()) do
  1054.                 if v:IsA("BasePart") then
  1055.                     --v.Massless = true
  1056.                     if v:CanSetNetworkOwnership() then
  1057.                         v:SetNetworkOwner(targplr)
  1058.                     end
  1059.                 end
  1060.             end
  1061.         end
  1062.     end))
  1063.     local kb = 15
  1064.     local targtorso = pc:FindFirstChild("Torso") or pc:FindFirstChild("UpperTorso") or pc:FindFirstChild("Head") or pc:FindFirstChild("HumanoidRootPart")
  1065.     local dir = targtorso.CFrame.lookVector*-1
  1066.     local bv = Instance.new("BodyVelocity")
  1067.     bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  1068.     bv.Velocity = --[[dir*kb+]]Vector3.new(0,kb,0)
  1069.     bv.Parent = targtorso
  1070.     game:GetService("Debris"):AddItem(bv,0.1)
  1071.     local ragval = Instance.new("ObjectValue")
  1072.     ragval.Name = 'Ragdolled'
  1073.     ragval.Parent = targhum
  1074.     spawn(function()
  1075.         for _,m in pairs(pc:GetChildren()) do
  1076.             for _,v in pairs(m:GetChildren()) do
  1077.                 if v:IsA("Snap") or v:IsA('Weld') then
  1078.                     v:Destroy()
  1079.                 end
  1080.                 if (v:IsA('Motor6D') or v:IsA('Motor')) and v.Parent:IsA("Part") then
  1081.                     if not kill then
  1082.                         table.insert(js2,1,{obj = v,par = v.Parent})
  1083.                     end
  1084.  
  1085.                     local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
  1086.                     a0.CFrame = v.C0
  1087.                     a1.CFrame = v.C1
  1088.                     a0.Parent = v.Part0
  1089.                     a1.Parent = v.Part1
  1090.  
  1091.                     local b = Instance.new("BallSocketConstraint")
  1092.                     b.Attachment0 = a0
  1093.                     b.Attachment1 = a1
  1094.                     b.Parent = v.Part0
  1095.  
  1096.                     v.Parent = nil
  1097.                     table.insert(js,1,b)
  1098.                 end
  1099.             end
  1100.         end
  1101.     end)
  1102.     pcall(function()
  1103.         pc.HumanoidRootPart.CanCollide = false
  1104.     end)
  1105.     return js,js2
  1106. end
  1107.  
  1108. function fire(mousepos,t,ignore)
  1109.     local p1 = head.Position
  1110.     local p2 = (mousepos-p1).Unit
  1111.     local result = raycast(p1, p2, 1000, ignore)
  1112.     if result then
  1113.         local obj = result.Instance
  1114.         local targplr,targchar,targhum,targtorso,targhead
  1115.  
  1116.         targchar = obj.Parent
  1117.         targplr = game:GetService("Players"):GetPlayerFromCharacter(targchar)
  1118.         for i,v in pairs(game:GetService("Players"):GetChildren()) do
  1119.             if v.Character and obj:IsDescendantOf(v.Character) then
  1120.                 targchar = v.Character
  1121.                 break
  1122.             end
  1123.         end
  1124.         targhum = targchar:FindFirstChildOfClass("Humanoid")
  1125.         targtorso = targchar:FindFirstChild("Torso") or targchar:FindFirstChild("UpperTorso") or targchar:FindFirstChild("HumanoidRootPart")
  1126.         targhead = targchar:FindFirstChild("Head")
  1127.  
  1128.         if exists(targchar) and targchar ~= char then
  1129.             if not obj:FindFirstChild('Dismembered') then
  1130.                 local dmg = 0
  1131.                 if obj.Name == 'Head' then
  1132.                     dmg = math.random(15,17)
  1133.                 elseif obj == targtorso or obj == targchar:FindFirstChild("HumanoidRootPart") then
  1134.                     dmg = math.random(12,14)
  1135.                 else
  1136.                     dmg = math.random(7,11)
  1137.                 end
  1138.                 if 0 >= (targhum.Health - dmg) then
  1139.                     targhum.BreakJointsOnDeath = false
  1140.                 end
  1141.                 targhum:TakeDamage(dmg)
  1142.  
  1143.                 if math.random(1,10) == 1 and obj.Parent == targchar then
  1144.                     if obj.Name == 'Head' then
  1145.                         targhum.BreakJointsOnDeath = false
  1146.                     end
  1147.                     break_limb(obj,targchar,p2)
  1148.                 end
  1149.  
  1150.                 if not targhum:FindFirstChild("killer") then
  1151.                     if not alive(targchar) then
  1152.                         wait()
  1153.                         if obj.Name == 'Head' and obj.Parent == targchar then
  1154.                             break_limb(obj,targchar,p2)
  1155.                         end
  1156.                         kill(targchar,p2,15)
  1157.                     elseif not targtorso:FindFirstChild("pain groan") then
  1158.                         local pg = {1489922915,1489934368}
  1159.                         local stuns = {
  1160.                             5169623605,
  1161.                             5169624072,
  1162.                             5169626214,
  1163.                             5169624072,
  1164.                             5169623821,
  1165.                             5169626595
  1166.                         }
  1167.                         local groan = Instance.new("Sound")
  1168.                         groan.Name = 'pain groan'
  1169.                         groan.SoundId = 'rbxassetid://' .. stuns[math.random(1,#stuns)]
  1170.                         groan.Volume = 1
  1171.                         groan.Parent = targtorso
  1172.                         groan:Play()
  1173.                         game:GetService("Debris"):AddItem(groan,groan.TimeLength)
  1174.                     end
  1175.                 end
  1176.             end
  1177.             --bleed2(obj,targhum,true,3,true,p2)
  1178.             if obj.Parent == targchar then
  1179.                 if obj == targchar:FindFirstChild("HumanoidRootPart") then
  1180.                     add_blood(targtorso)
  1181.                 else
  1182.                     add_blood(obj)
  1183.                 end
  1184.             end
  1185.         --[[
  1186.         elseif 1 >= t then
  1187.             break_window(obj)
  1188.             fire(mousepos,t+1,{unpack(ignore),obj})
  1189.         ]]
  1190.         end
  1191.     end
  1192. end
  1193.  
  1194. function shoot(mousepos)
  1195.     using = true
  1196.     for i = 1,bulletfire do
  1197.         if 0 >= ammo then
  1198.             using = false
  1199.             reload()
  1200.             return
  1201.         end
  1202.         game:GetService("TweenService"):Create(tool,TweenInfo.new(0.2),{
  1203.             Grip = grips.shooting
  1204.         }):Play()
  1205.         shoots['shoot' .. i]:Play()
  1206.         if not op then
  1207.             ammo = ammo - 1
  1208.         end
  1209.         usefx()
  1210.         drop_shell()
  1211.         bullet_trail(mousepos)
  1212.         remote:FireClient(plr,1,recoil)
  1213.         --
  1214.        
  1215.         local ignore = {char,script}
  1216.         --[[ shitty server cant handle this
  1217.         for _,p in ipairs(game:GetService("Players"):GetPlayers()) do
  1218.             if p.Character then
  1219.                 for i,v in ipairs(p.Character:GetChildren()) do
  1220.                     if v:IsA("Accessory") or v:IsA("Tool") then
  1221.                         table.insert(ignore,1,v)
  1222.                     end
  1223.                 end
  1224.             end
  1225.         end
  1226.         ]]
  1227.         fire(mousepos,1,ignore)
  1228.  
  1229.         --
  1230.         if not op then
  1231.             wait(shootwait)
  1232.         else
  1233.             wait(0)
  1234.         end
  1235.         game:GetService("TweenService"):Create(tool,TweenInfo.new(0.2),{
  1236.             Grip = grips.equipped
  1237.         }):Play()
  1238.     end
  1239.     using = false
  1240. end
  1241.  
  1242. tool.Equipped:Connect(function()
  1243.     equipped = true
  1244.     equip:Play()
  1245. end)
  1246.  
  1247. tool.Unequipped:Connect(function()
  1248.     equipped = false
  1249.     equip:Stop()
  1250. end)
  1251.  
  1252. remote = script:FindFirstChild('RemoteEvent') or tool:FindFirstChild('RemoteEvent') or Instance.new('RemoteEvent')
  1253. remote.Parent = tool
  1254.  
  1255. remote.OnServerEvent:Connect(function(lplr,mode,data,data2)
  1256.     if (plr == lplr) and not using and alive(char) and equipped then
  1257.         if mode == 1 and data then -- shoot
  1258.             shoot(data)
  1259.         elseif mode == 2 then -- reload
  1260.             reload()
  1261.         end
  1262.     end
  1263. end)
  1264.  
  1265. NLS([[
  1266. local plr = game:GetService("Players").LocalPlayer
  1267. local remote = script.Parent
  1268. local mouse = plr:GetMouse()
  1269. local uis = game:GetService("UserInputService")
  1270. local bulletfire = 3
  1271. local shootwait = 0.2/bulletfire
  1272. local firemode = 3 -- 1 = semi, 2 = auto, 3 = burst
  1273. local shooting = true
  1274.  
  1275. local camera = workspace.CurrentCamera
  1276.  
  1277. function cam_recoil()
  1278.     spawn(function()
  1279.         local r = 1000
  1280.         local r2 = r/3
  1281.         local x = (math.random(r/10,r)/r2)/(r/4) -- real y
  1282.         local y = (math.random(-r,r)/r2)/(r/3) -- fake y
  1283.         local z = (math.random(-r,r)/r2)/(r/4)
  1284.         local t = 0.1
  1285.         local m = 60
  1286.         for i = t*m,1,-1 do
  1287.             local ct = m/m/i
  1288.             camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(x*ct,y*ct,z*ct)
  1289.             game:GetService("RunService").RenderStepped:Wait()
  1290.         end
  1291.     end)
  1292. end
  1293.  
  1294. remote.OnClientEvent:Connect(function(mode)
  1295.     if mode then else return end
  1296.     if mode == 1 then
  1297.         cam_recoil()
  1298.     end
  1299. end)
  1300.  
  1301. uis.InputBegan:Connect(function(input,gamepress)
  1302.     if gamepress then return end
  1303.     if input.UserInputType == Enum.UserInputType.Keyboard then
  1304.         local key = input.KeyCode
  1305.         if key == Enum.KeyCode.R then
  1306.             remote:FireServer(2)
  1307.         end
  1308.     elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  1309.         shooting = true
  1310.         if firemode == 1 then -- semi
  1311.             remote:FireServer(1,mouse.Hit.p)
  1312.         elseif firemode == 2 then -- auto
  1313.             while shooting do
  1314.                 remote:FireServer(1,mouse.Hit.p)
  1315.                 wait(shootwait)
  1316.             end
  1317.         elseif firemode == 3 then -- burst
  1318.             remote:FireServer(1,mouse.Hit.p)
  1319.         end
  1320.     end
  1321. end)
  1322.  
  1323. uis.InputEnded:Connect(function(input,gamepress)
  1324.     if gamepress then return end
  1325.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  1326.         shooting = false
  1327.     end
  1328. end)
  1329. ]],remote)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement