Advertisement
subaru112g

garry's mod weapon script

Sep 13th, 2018
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.72 KB | None | 0 0
  1. --Getting the player, character and mouse
  2. local plr = game.Players.LocalPlayer
  3. local char = plr.Character
  4. local Mouse = plr:GetMouse()
  5. local mtarget
  6. --Making the tool
  7. local gun = Instance.new("Tool",plr.Backpack)
  8. gun.Name = "weapon"
  9. gun.GripPos = Vector3.new(0, -1.315, -0.253)
  10. gun.GripUp = Vector3.new(0, -0, 1)
  11. local handle = Instance.new("Part",gun)
  12. handle.Name = "Handle"
  13. handle.Size = Vector3.new(0.3, 4.9, 0.8)
  14. local mesh = Instance.new("SpecialMesh",handle)
  15. mesh.MeshId = "http://www.roblox.com/asset/?id=42583419"
  16. mesh.MeshType = "FileMesh"
  17. mesh.Scale = Vector3.new(1.5, 1.5, 1.5)
  18. mesh.TextureId = "http://www.roblox.com/asset/?id=42584198"
  19. local bullet = Instance.new("Model",gun)
  20. bullet.Name = "bullet"
  21. local p1 = Instance.new("Part",bullet)
  22. p1.Shape = "Ball"
  23. p1.Name = "p1"
  24. p1.Size = Vector3.new(0.9, 0.9, 0.9)
  25. p1.Material = "Neon"
  26. p1.BrickColor = BrickColor.new("Really blue")
  27. p1.Transparency = 1
  28. p1.CanCollide = false
  29. p1.BottomSurface = "Smooth"
  30. p1.TopSurface = "Smooth"
  31. local p2 = Instance.new("Part",bullet)
  32. p2.Shape = "Ball"
  33. p2.Name = "p2"
  34. p2.Size = Vector3.new(1, 1, 1)
  35. p2.Material = "Plastic"
  36. p2.BrickColor = BrickColor.new("Institutional white")
  37. p2.Transparency = 1
  38. p2.CanCollide = false
  39. p2.BottomSurface = "Smooth"
  40. p2.TopSurface = "Smooth"
  41. local shoot = Instance.new("Sound",handle)
  42. shoot.SoundId = "rbxassetid://2344851316"
  43. shoot.Volume = 1
  44. local canshoot = false
  45. --Making the welds
  46. local w1 = Instance.new("Weld",p1)
  47. w1.Part0 = p1
  48. w1.Part1 = handle
  49. w1.C0 = CFrame.new(0, 0, 0, 1, 1.19208686e-07, -2.72848411e-12, 1.19208686e-07, 1, 1.15107923e-12, -2.72848411e-12, 1.15107923e-12, 1)
  50. w1.C1 = CFrame.new(-0.0999778807, 3.69987226, 0.299981654, 1, 1.19208686e-07, -2.72848411e-12, 1.19208686e-07, 1, 1.15107923e-12, -2.72848411e-12, 1.15107923e-12, 1)
  51. w1.Name = "hWeld"
  52. local w2 = Instance.new("Weld",p1)
  53. w2.Part0 = p1
  54. w2.Part1 = p2
  55. w2.C0 = CFrame.new(0.299996376, -5.29999924, 1.5, 0.999998569, 5.96042923e-07, -1.36423997e-11, 5.96043094e-07, 1, 5.75538922e-12, -1.36423997e-11, 5.75538749e-12, 0.999998569)
  56. w2.C1 = CFrame.new(0.300022125, -5.30012798, 1.49998176, 1, 1.19208686e-07, -2.72848411e-12, 1.19208686e-07, 1, 1.15107923e-12, -2.72848411e-12, 1.15107923e-12, 1)
  57. --Functions
  58. gun.Equipped:connect(function()
  59. local weld = Instance.new("Weld",char)
  60. weld.Name = "Weld"
  61. weld.Part0 = char.Torso
  62. weld.Part1 = char["Left Arm"]
  63. weld.C1 = CFrame.new(0.199999988, 0.699999988, 0, 0.642787516, 7.6651645e-09, -0.766044438, 0.766044438, 9.13498788e-09, 0.642787516, 1.19248806e-08, -0.99999994, -5.21253064e-16)
  64. weld.C0 = CFrame.new(-1, 0.5, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  65. local weld2 = Instance.new("Weld",char)
  66. weld2.Part0 = char.Torso
  67. weld2.Part1 = char["Right Arm"]
  68. weld2.C1 = CFrame.new(0, 0.49999997, 0, -4.37113847e-08, 0, 0.99999994, -1, -4.37113847e-08, -4.37113883e-08, 4.37113883e-08, -0.99999994, 1.91068547e-15)
  69. weld2.C0 = CFrame.new(1, 0.5, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  70. weld2.Name = "Weld2"
  71. canshoot = true
  72. end)
  73.  
  74. gun.Unequipped:connect(function()
  75. char.Weld:Destroy()
  76. char.Weld2:Destroy()
  77. canshoot = false
  78. end)
  79.  
  80.  
  81. function clickObj()
  82. if canshoot == true then
  83. mtarget = Mouse.Target
  84. if mtarget then
  85. shoot:Play()
  86. local bulc = bullet:Clone()
  87. bulc.Parent = game.Workspace
  88. bulc.p1.Transparency = 0.5
  89. bulc.p2.Transparency = 0.5
  90. bulc.p1.hWeld:Destroy()
  91. bulc.p2.CanCollide = true
  92. local bv = Instance.new("BodyVelocity")
  93. bv.Parent = bulc.p2
  94. bv.velocity = ((char.Humanoid.TargetPoint - bulc.p2.Position).unit) * 50
  95.  
  96. function onTouched(brick)
  97. local humn = brick.Parent:FindFirstChildOfClass("Humanoid")
  98. if humn then
  99. if humn.Parent ~= char then
  100. if humn.Name ~= "killed" then
  101. local par = humn.Parent
  102.  
  103. for i,v in pairs(par:GetChildren()) do
  104. if v.ClassName == "Script" or v.ClassName == "LocalScript" or v.ClassName == "ModuleScript" or v.ClassName == "CharacterMesh" then
  105. v:Destroy()
  106. end
  107. end
  108.  
  109. par.Torso["Right Hip"].Part1 = nil
  110. par.Torso["Left Hip"].Part1 = nil
  111. par.Torso["Right Shoulder"].Part1 = nil
  112. par.Torso["Left Shoulder"].Part1 = nil
  113.  
  114. for i,v in pairs(par:GetChildren()) do
  115. if v.ClassName == "Part" then
  116. v.BrickColor = BrickColor.new("Institutional white")
  117. v.Material = "Neon"
  118. if v.Name == "limb" then
  119. v:Destroy()
  120. end
  121. end
  122. end
  123.  
  124. for i,v in pairs(par.Head:GetChildren()) do
  125. if v.ClassName == "Decal" then
  126. v:Destroy()
  127. end
  128. end
  129.  
  130. for i,v in pairs(par.Head:GetChildren()) do
  131. if v.ClassName == "Part" then
  132. v.Anchored = false
  133. end
  134. end
  135.  
  136. for i,v in pairs(par:GetChildren()) do
  137. if v.ClassName == "Hat" or v.ClassName == "Accessory" then
  138. v.Handle.BrickColor = BrickColor.new("Institutional white")
  139. v.Handle.Material = "Neon"
  140. for i,v in pairs(v.Handle:GetChildren()) do
  141. if v.ClassName == "SpecialMesh" then
  142. v.TextureId = ""
  143. end
  144. end
  145. end
  146. end
  147.  
  148. humn.Name = "killed"
  149.  
  150. local bp = Instance.new("BodyPosition",par["Right Arm"])
  151. bp.Position = par["Right Arm"].Position
  152. bp.Position = bp.Position + Vector3.new(0,8,0)
  153.  
  154. local bp = Instance.new("BodyPosition",par["Left Leg"])
  155. bp.Position = par["Left Leg"].Position
  156. bp.Position = bp.Position + Vector3.new(0,4,0)
  157.  
  158. local bp = Instance.new("BodyPosition",par.Torso)
  159. bp.Position = par.Torso.Position
  160. bp.Position = bp.Position + Vector3.new(0,2,0)
  161.  
  162. local bp = Instance.new("BodyPosition",par["Left Arm"])
  163. bp.Position = par["Left Arm"].Position
  164. bp.Position = bp.Position + Vector3.new(0,2,0)
  165.  
  166. local bp = Instance.new("BodyPosition",par["Right Leg"])
  167. bp.Position = par["Right Leg"].Position
  168. bp.Position = bp.Position + Vector3.new(0,2,0)
  169.  
  170. local rac = Instance.new("Part",par)
  171. rac.Size = Vector3.new(1,1,1)
  172. rac.Position = par["Right Arm"].Position
  173. rac.Name = "limb"
  174. rac.Transparency = 1
  175. local w = Instance.new("Weld",rac)
  176. w.Part0 = par["Right Arm"]
  177. w.Part1 = rac
  178. w.C0 = CFrame.new(0,-0.5,0)
  179.  
  180. local lac = Instance.new("Part",par)
  181. lac.Size = Vector3.new(1,1,1)
  182. lac.Position = par["Left Arm"].Position
  183. lac.Name = "limb"
  184. lac.Transparency = 1
  185. local w = Instance.new("Weld",lac)
  186. w.Part0 = par["Left Arm"]
  187. w.Part1 = lac
  188. w.C0 = CFrame.new(0,-0.5,0)
  189.  
  190. local rlc = Instance.new("Part",par)
  191. rlc.Size = Vector3.new(1,1,1)
  192. rlc.Position = par["Right Leg"].Position
  193. rlc.Name = "limb"
  194. rlc.Transparency = 1
  195. local w = Instance.new("Weld",rlc)
  196. w.Part0 = par["Right Leg"]
  197. w.Part1 = rlc
  198. w.C0 = CFrame.new(0,-0.5,0)
  199.  
  200. local llc = Instance.new("Part",par)
  201. llc.Size = Vector3.new(1,1,1)
  202. llc.Position = par["Right Leg"].Position
  203. llc.Name = "limb"
  204. llc.Transparency = 1
  205. local w = Instance.new("Weld",llc)
  206. w.Part0 = par["Left Leg"]
  207. w.Part1 = llc
  208. w.C0 = CFrame.new(0,-0.5,0)
  209.  
  210. local Joint = Instance.new("Glue")
  211. Joint.Name = "RightShoulder"
  212. Joint.Part0 = par.Torso
  213. Joint.Part1 = par["Right Arm"]
  214. Joint.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  215. Joint.C1 = CFrame.new(-0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  216. Joint.Parent = par.Torso
  217.  
  218. local Joint = Instance.new("Glue")
  219. Joint.Name = "LeftShoulder"
  220. Joint.Part0 = par.Torso
  221. Joint.Part1 = par["Left Arm"]
  222. Joint.C0 = CFrame.new(-1.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  223. Joint.C1 = CFrame.new(0, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  224. Joint.Parent = par.Torso
  225.  
  226. local Joint = Instance.new("Glue")
  227. Joint.Name = "RightHip"
  228. Joint.Part0 = par.Torso
  229. Joint.Part1 = par["Right Leg"]
  230. Joint.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  231. Joint.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  232. Joint.Parent = par.Torso
  233.  
  234. local Joint = Instance.new("Glue")
  235. Joint.Name = "LeftHip"
  236. Joint.Part0 = par.Torso
  237. Joint.Part1 = par["Left Leg"]
  238. Joint.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  239. Joint.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  240. Joint.Parent = par.Torso
  241.  
  242. humn.PlatformStand = true
  243. wait(4.5)
  244. for i,v in pairs(par:GetChildren()) do
  245. if v.ClassName == "Part" then
  246. local w1 = Instance.new("WedgePart",workspace)
  247. w1.Size = Vector3.new(0.5,0.5,0.5)
  248. w1.Position = v.Position
  249. w1.Material = "Neon"
  250. local w2 = Instance.new("WedgePart",workspace)
  251. w2.Size = Vector3.new(0.5,0.5,0.5)
  252. w2.Position = v.Position
  253. w2.Material = "Neon"
  254. v:Destroy()
  255. end
  256. end
  257. end
  258. bulc:Destroy()
  259. end
  260. end
  261. end
  262. bulc.p2.Touched:connect(onTouched)
  263. end
  264. end
  265. end
  266. Mouse.Button1Down:connect(clickObj)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement