lotushomerun

M1A1 Thompson Script(Roblox)

May 19th, 2017
2,958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.68 KB | None | 0 0
  1. --A M1A1 Thompsion ^-^
  2. --Has a 35 round magazine and does lots of damage
  3. --Don't leak this. If you do i will fucking shoot you till your dead :\
  4. local runDummyScript = function(f,scri)
  5. local oldenv = getfenv(f)
  6. local newenv = setmetatable({}, {
  7. __index = function(_, k)
  8. if k:lower() == 'script' then
  9. return scri
  10. else
  11. return oldenv[k]
  12. end
  13. end
  14. })
  15. setfenv(f, newenv)
  16. ypcall(function() f() end)
  17. end
  18. cors = {}
  19. mas = Instance.new("Model",game:GetService("Lighting"))
  20. mas.Name = "CompiledModel"
  21. o1 = Instance.new("Tool")
  22. o2 = Instance.new("Part")
  23. o3 = Instance.new("Sound")
  24. o4 = Instance.new("Sound")
  25. o5 = Instance.new("Sound")
  26. o6 = Instance.new("PointLight")
  27. o7 = Instance.new("Sound")
  28. o8 = Instance.new("SpecialMesh")
  29. o10 = Instance.new("Animation")
  30. o11 = Instance.new("ScreenGui")
  31. o12 = Instance.new("Frame")
  32. o13 = Instance.new("TextLabel")
  33. o14 = Instance.new("TextLabel")
  34. o15 = Instance.new("TextLabel")
  35. o16 = Instance.new("Frame")
  36. o17 = Instance.new("Frame")
  37. o18 = Instance.new("Frame")
  38. o19 = Instance.new("Frame")
  39. o20 = Instance.new("ImageLabel")
  40. o21 = Instance.new("TextLabel")
  41. o22 = Instance.new("Frame")
  42. o23 = Instance.new("Frame")
  43. o24 = Instance.new("TextLabel")
  44. o25 = Instance.new("LocalScript")
  45. o26 = Instance.new("LocalScript")
  46. o27 = Instance.new("Script")
  47. o1.Name = "Thompson"
  48. o1.Parent = game.Players.LocalPlayer.Backpack
  49. o1.GripForward = Vector3.new(0.248, 0, 0.969)
  50. o1.GripPos = Vector3.new(0, -0.2, -0.5)
  51. o1.GripRight = Vector3.new(-0.969, 0, 0.248)
  52. o1.GripUp = Vector3.new(0, 1, 0)
  53. o1.ToolTip = "M16A2"
  54. o2.Name = "Handle"
  55. o2.Parent = o1
  56. o2.BrickColor = BrickColor.new("Black")
  57. --o2.Transparency = 1
  58. o2.Position = Vector3.new(14.1037359, 10.9526501, 14.6426458)
  59. o2.Rotation = Vector3.new(0, -180, 0)
  60. o2.FormFactor = Enum.FormFactor.Custom
  61. o2.Size = Vector3.new(0.7, 0.4, 3.51)
  62. --o2.CFrame = CFrame.new(14.1037359, 10.9526501, 14.6426458, 1.00000787, 2.84217094e-14, -1.94057783e-13, -2.18925247e-13, 2.14719495e-26, 1, 2.84217094e-14, -1.00000787, -2.82727748e-26)
  63. o2.BottomSurface = Enum.SurfaceType.Smooth
  64. o2.TopSurface = Enum.SurfaceType.Smooth
  65. o2.Color = Color3.new(0.105882, 0.164706, 0.207843)
  66. o3.Name = "FireSound"
  67. o3.Parent = o2
  68. o3.Pitch = 0.89999997615814
  69. o3.SoundId = "rbxassetid://132456294"
  70. o3.Volume = 1
  71. o4.Name = "Reload"
  72. o4.Parent = o2
  73. o4.SoundId = "http://www.roblox.com/asset/?id=132456068"
  74. o4.Volume = 1
  75. o5.Name = "EquipSound"
  76. o5.Parent = o2
  77. o5.SoundId = "http://www.roblox.com/asset/?id=10209881"
  78. o5.Volume = 1
  79. o6.Name = "Flash"
  80. o6.Parent = o2
  81. o6.Color = Color3.new(1, 1, 0)
  82. o6.Enabled = false
  83. o6.Brightness = 1.5
  84. o7.Name = "Tick"
  85. o7.Parent = o2
  86. o7.SoundId = "rbxasset://sounds//clickfast.wav"
  87. o7.Volume = 1
  88. o8.Parent = o2
  89. o8.MeshId = "http://www.roblox.com/asset/?id=478417984"
  90. o8.Scale = Vector3.new(0.005, 0.005, 0.005)
  91. o8.TextureId = "http://www.roblox.com/asset/?id=478418082"
  92. o8.VertexColor = Vector3.new(2, 2, 2)
  93. o8.MeshType = Enum.MeshType.FileMesh
  94. o10.Name = "Recoil"
  95. o10.Parent = o1
  96. o10.AnimationId = "http://www.roblox.com/Asset?ID=94331086"
  97. o11.Name = "WeaponHud"
  98. o11.Parent = o1
  99. o12.Name = "AmmoHud"
  100. o12.Parent = o11
  101. o12.Position = UDim2.new(1,-265,1,-60)
  102. o12.Size = UDim2.new(0,200,0,50)
  103. o12.Style = Enum.FrameStyle.RobloxSquare
  104. o12.Position = UDim2.new(1,-265,1,-60)
  105. o12.BackgroundTransparency = 1
  106. o12.BorderSizePixel = 0
  107. o13.Name = "ForwardSlash"
  108. o13.Parent = o12
  109. o13.Position = UDim2.new(0.5,0,0.5,0)
  110. o13.Text = "/"
  111. o13.Position = UDim2.new(0.5,0,0.5,0)
  112. o13.BackgroundTransparency = 1
  113. o13.BorderSizePixel = 0
  114. o13.FontSize = Enum.FontSize.Size24
  115. o13.TextColor3 = Color3.new(1, 1, 1)
  116. o13.TextStrokeTransparency = 0
  117. o14.Name = "ClipAmmo"
  118. o14.Parent = o12
  119. o14.Position = UDim2.new(0.44999998807907,0,0.5,0)
  120. o14.Text = "54"
  121. o14.Position = UDim2.new(0.44999998807907,0,0.5,0)
  122. o14.BackgroundTransparency = 1
  123. o14.BorderSizePixel = 0
  124. o14.FontSize = Enum.FontSize.Size24
  125. o14.TextColor3 = Color3.new(1, 1, 1)
  126. o14.TextStrokeTransparency = 0
  127. o14.TextXAlignment = Enum.TextXAlignment.Right
  128. o15.Name = "TotalAmmo"
  129. o15.Parent = o12
  130. o15.Position = UDim2.new(0.55000001192093,0,0.5,0)
  131. o15.Text = "180"
  132. o15.Position = UDim2.new(0.55000001192093,0,0.5,0)
  133. o15.BackgroundTransparency = 1
  134. o15.BorderSizePixel = 0
  135. o15.FontSize = Enum.FontSize.Size24
  136. o15.TextColor3 = Color3.new(1, 1, 1)
  137. o15.TextStrokeTransparency = 0
  138. o15.TextXAlignment = Enum.TextXAlignment.Left
  139. o16.Name = "Crosshair"
  140. o16.Parent = o11
  141. o16.Position = UDim2.new(0,500,0,500)
  142. o16.Size = UDim2.new(0,150,0,150)
  143. o16.Position = UDim2.new(0,500,0,500)
  144. o16.BackgroundColor3 = Color3.new(0, 1, 0)
  145. o16.BackgroundTransparency = 1
  146. o16.BorderSizePixel = 0
  147. o17.Name = "TopFrame"
  148. o17.Parent = o16
  149. o17.Position = UDim2.new(0,-1,-0.5,-7)
  150. o17.Size = UDim2.new(0,2,0,14)
  151. o17.Position = UDim2.new(0,-1,-0.5,-7)
  152. o17.BackgroundColor3 = Color3.new(1, 1, 1)
  153. o17.BorderColor3 = Color3.new(0, 0, 0)
  154. o18.Name = "RightFrame"
  155. o18.Parent = o16
  156. o18.Position = UDim2.new(0.5,-7,0,-1)
  157. o18.Size = UDim2.new(0,14,0,2)
  158. o18.Position = UDim2.new(0.5,-7,0,-1)
  159. o18.BackgroundColor3 = Color3.new(1, 1, 1)
  160. o18.BorderColor3 = Color3.new(0, 0, 0)
  161. o19.Name = "LeftFrame"
  162. o19.Parent = o16
  163. o19.Position = UDim2.new(-0.5,-7,0,-1)
  164. o19.Size = UDim2.new(0,14,0,2)
  165. o19.Position = UDim2.new(-0.5,-7,0,-1)
  166. o19.BackgroundColor3 = Color3.new(1, 1, 1)
  167. o19.BorderColor3 = Color3.new(0, 0, 0)
  168. o20.Name = "TargetHitImage"
  169. o20.Parent = o16
  170. o20.Position = UDim2.new(0,-25,0,-25)
  171. o20.Size = UDim2.new(0,50,0,50)
  172. o20.Position = UDim2.new(0,-25,0,-25)
  173. o20.Visible = false
  174. o20.BackgroundTransparency = 1
  175. o20.BorderSizePixel = 0
  176. o20.Image = "http://www.roblox.com/asset/?id=115400215"
  177. o21.Name = "ReloadingLabel"
  178. o21.Parent = o16
  179. o21.Position = UDim2.new(0,20,0,-20)
  180. o21.Text = "Reloading"
  181. o21.Position = UDim2.new(0,20,0,-20)
  182. o21.Visible = false
  183. o21.BackgroundTransparency = 1
  184. o21.BorderSizePixel = 0
  185. o21.Font = Enum.Font.ArialBold
  186. o21.FontSize = Enum.FontSize.Size18
  187. o21.TextColor3 = Color3.new(1, 1, 1)
  188. o21.TextStrokeTransparency = 0
  189. o21.TextXAlignment = Enum.TextXAlignment.Left
  190. o21.TextYAlignment = Enum.TextYAlignment.Bottom
  191. o22.Name = "BottomFrame"
  192. o22.Parent = o16
  193. o22.Position = UDim2.new(0,-1,0.5,-7)
  194. o22.Size = UDim2.new(0,2,0,14)
  195. o22.Position = UDim2.new(0,-1,0.5,-7)
  196. o22.BackgroundColor3 = Color3.new(1, 1, 1)
  197. o22.BorderColor3 = Color3.new(0, 0, 0)
  198. o23.Name = "Reload"
  199. o23.Parent = o11
  200. o23.Position = UDim2.new(1,-265,1,-120)
  201. o23.Size = UDim2.new(0,200,0,50)
  202. o23.Position = UDim2.new(1,-265,1,-120)
  203. o23.Visible = false
  204. o23.BackgroundTransparency = 1
  205. o23.BorderSizePixel = 0
  206. o24.Name = "Reload"
  207. o24.Parent = o23
  208. o24.Position = UDim2.new(0.5,0,0.5,0)
  209. o24.Text = "Press R to Reload"
  210. o24.Position = UDim2.new(0.5,0,0.5,0)
  211. o24.BackgroundTransparency = 1
  212. o24.BorderSizePixel = 0
  213. o24.Font = Enum.Font.ArialBold
  214. o24.FontSize = Enum.FontSize.Size24
  215. o24.TextColor3 = Color3.new(1, 0, 0)
  216. o24.TextStrokeTransparency = 0
  217. o25.Name = "ArmWeld [Rifle]"
  218. o25.Parent = o1
  219. print("Giving "..game.Players.LocalPlayer.Name.. " a " ..o1.Name.. "Don't leak this. If you do i will fucking shoot you till your dead ;\ ")
  220. table.insert(cors,coroutine.create(function()
  221. wait()
  222. runDummyScript(function()
  223. Tool = o1;
  224.  
  225. local arms = nil
  226. local torso = nil
  227. local welds = {}
  228.  
  229. function Equip(mouse)
  230. wait(0.01)
  231. arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
  232. torso = Tool.Parent:FindFirstChild("Torso")
  233. if arms ~= nil and torso ~= nil then
  234. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  235. if sh ~= nil then
  236. local yes = true
  237. if yes then
  238. yes = false
  239. sh[1].Part1 = nil
  240. sh[2].Part1 = nil
  241. local weld1 = Instance.new("Weld")
  242. weld1.Part0 = torso
  243. weld1.Parent = torso
  244. weld1.Part1 = arms[1]
  245. weld1.C1 = CFrame.new(-.1, 1.2, .6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90)) ---The first set of numbers changes where the arms move to the second set changes their angles
  246. welds[1] = weld1
  247. weld1.Name = "weld1"
  248. local weld2 = Instance.new("Weld")
  249. weld2.Part0 = torso
  250. weld2.Parent = torso
  251. weld2.Part1 = arms[2]
  252. weld2.C1 = CFrame.new(-1, -0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0) --- Same as top
  253. welds[2] = weld2
  254. weld2.Name = "weld2"
  255. end
  256. else
  257. print("sh")
  258. end
  259. else
  260. print("arms")
  261. end
  262. end
  263.  
  264. function Unequip(mouse)
  265. if arms ~= nil and torso ~= nil then
  266. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  267. if sh ~= nil then
  268. local yes = true
  269. if yes then
  270. yes = false
  271. sh[1].Part1 = arms[1]
  272. sh[2].Part1 = arms[2]
  273. welds[1].Parent = nil
  274. welds[2].Parent = nil
  275. end
  276. else
  277. print("sh")
  278. end
  279. else
  280. print("arms")
  281. end
  282. end
  283. Tool.Equipped:connect(Equip)
  284. Tool.Unequipped:connect(Unequip)
  285.  
  286. end,o25)
  287. end))
  288. o26.Name = "Thompson"
  289. o26.Parent = o1
  290. table.insert(cors,coroutine.create(function()
  291. wait()
  292. runDummyScript(function()
  293. --------------------- TEMPLATE ASSAULT RIFLE WEAPON ---------------------------
  294. -- Waits for the child of the specified parent
  295. local function WaitForChild(parent, childName)
  296.     while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  297.     return parent[childName]
  298. end
  299.  
  300. ----- MAGIC NUMBERS ABOUT THE TOOL -----
  301. -- How much damage a bullet does
  302. local Damage = 45
  303. -- How many times per second the gun can fire
  304. local FireRate = 1 / 11
  305. -- The maximum distance the can can shoot, this value should never go above 1000
  306. local Range = 850
  307. -- In radians the minimum accuracy penalty
  308. local MinSpread = 0
  309. -- In radian the maximum accuracy penalty
  310. local MaxSpread = 0
  311. -- Number of bullets in a clip
  312. local ClipSize = 35
  313. -- DefaultValue for spare ammo
  314. local SpareAmmo = math.huge
  315. -- The amount the aim will increase or decrease by
  316. -- decreases this number reduces the speed that recoil takes effect
  317. local AimInaccuracyStepAmount = 0.001
  318. -- Time it takes to reload weapon
  319. local ReloadTime = 2.8
  320. ----------------------------------------
  321.  
  322. -- Colors
  323. local FriendlyReticleColor = Color3.new(0, 1, 0)
  324. local EnemyReticleColor = Color3.new(1, 0, 0)
  325. local NeutralReticleColor   = Color3.new(1, 1, 1)
  326.  
  327. local Spread = MinSpread
  328. local AmmoInClip = ClipSize
  329.  
  330. local Tool = o1
  331. local Handle = WaitForChild(Tool, 'Handle')
  332. local WeaponGui = nil
  333.  
  334. local LeftButtonDown
  335. local Reloading = false
  336. local IsShooting = false
  337.  
  338. -- Player specific convenience variables
  339. local MyPlayer = nil
  340. local MyCharacter = nil
  341. local MyHumanoid = nil
  342. local MyTorso = nil
  343. local MyMouse = nil
  344.  
  345. local RecoilAnim
  346. local RecoilTrack = nil
  347.  
  348. local IconURL = Tool.TextureId  -- URL to the weapon icon asset
  349.  
  350. local DebrisService = game:GetService('Debris')
  351. local PlayersService = game:GetService('Players')
  352.  
  353.  
  354. local FireSound
  355.  
  356. local OnFireConnection = nil
  357. local OnReloadConnection = nil
  358.  
  359. local DecreasedAimLastShot = false
  360. local LastSpreadUpdate = time()
  361.  
  362. -- this is a dummy object that holds the flash made when the gun is fired
  363. local FlashHolder = nil
  364.  
  365.  
  366. local WorldToCellFunction = Workspace.Terrain.WorldToCellPreferSolid
  367. local GetCellFunction = Workspace.Terrain.GetCell
  368.  
  369. function RayIgnoreCheck(hit, pos)
  370.     if hit then
  371.         if hit.Transparency >= 1 or string.lower(hit.Name) == "water" or
  372.                 hit.Name == "Effect" or hit.Name == "Rocket" or hit.Name == "Bullet" or
  373.                 hit.Name == "Handle" or hit:IsDescendantOf(MyCharacter) then
  374.             return true
  375.         elseif hit:IsA('Terrain') and pos then
  376.             local cellPos = WorldToCellFunction(Workspace.Terrain, pos)
  377.             if cellPos then
  378.                 local cellMat = GetCellFunction(Workspace.Terrain, cellPos.x, cellPos.y, cellPos.z)
  379.                 if cellMat and cellMat == Enum.CellMaterial.Water then
  380.                     return true
  381.                 end
  382.             end
  383.         end
  384.     end
  385.     return false
  386. end
  387.  
  388. -- @preconditions: vec should be a unit vector, and 0 < rayLength <= 1000
  389. function RayCast(startPos, vec, rayLength)
  390.     local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle)
  391.     if hitObject and hitPos then
  392.         local distance = rayLength - (hitPos - startPos).magnitude
  393.         if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
  394.             -- there is a chance here for potential infinite recursion
  395.             return RayCast(hitPos, vec, distance)
  396.         end
  397.     end
  398.     return hitObject, hitPos
  399. end
  400.  
  401.  
  402.  
  403. function TagHumanoid(humanoid, player)
  404.     -- Add more tags here to customize what tags are available.
  405.     while humanoid:FindFirstChild('creator') do
  406.         humanoid:FindFirstChild('creator'):Destroy()
  407.     end
  408.     local creatorTag = Instance.new("ObjectValue")
  409.     creatorTag.Value = player
  410.     creatorTag.Name = "creator"
  411.     creatorTag.Parent = humanoid
  412.     DebrisService:AddItem(creatorTag, 1.5)
  413.  
  414.     local weaponIconTag = Instance.new("StringValue")
  415.     weaponIconTag.Value = IconURL
  416.     weaponIconTag.Name = "icon"
  417.     weaponIconTag.Parent = creatorTag
  418. end
  419.  
  420.  
  421. local function CreateBullet(bulletPos)
  422.     local bullet = Instance.new('Part', Workspace)
  423.     bullet.FormFactor = Enum.FormFactor.Custom
  424.     bullet.Size = Vector3.new(0.1, 0.1, 0.1)
  425.     bullet.BrickColor = BrickColor.new("Black")
  426.     bullet.Shape = Enum.PartType.Block
  427.     bullet.CanCollide = false
  428.     bullet.CFrame = CFrame.new(bulletPos)
  429.     bullet.Anchored = true
  430.     bullet.TopSurface = Enum.SurfaceType.Smooth
  431.     bullet.BottomSurface = Enum.SurfaceType.Smooth
  432.     bullet.Name = 'Bullet'
  433.     DebrisService:AddItem(bullet, 2.5)
  434.     return bullet
  435. end
  436.  
  437. local function Reload()
  438.     if not Reloading then
  439.         Reloading = true
  440.         -- Don't reload if you are already full or have no extra ammo
  441.         if AmmoInClip ~= ClipSize and SpareAmmo > 0 then
  442.             if RecoilTrack then
  443.                 RecoilTrack:Stop()
  444.             end
  445.             if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
  446.                 if WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
  447.                     WeaponGui.Crosshair.ReloadingLabel.Visible = true
  448.                 end
  449.             end
  450.             script.Parent.Handle.Reload:Play()
  451.             wait(ReloadTime)
  452.             -- Only use as much ammo as you have
  453.             local ammoToUse = math.min(ClipSize - AmmoInClip, SpareAmmo)
  454.             AmmoInClip = AmmoInClip + ammoToUse
  455.             SpareAmmo = SpareAmmo - ammoToUse
  456.             UpdateAmmo(AmmoInClip)
  457.             WeaponGui.Reload.Visible = false
  458.         end
  459.         Reloading = false
  460.     end
  461. end
  462.  
  463. function OnFire()
  464.     if IsShooting then return end
  465.     if MyHumanoid and MyHumanoid.Health > 0 then
  466.         if RecoilTrack and AmmoInClip > 0 then
  467.             RecoilTrack:Play()
  468.         end
  469.         IsShooting = true
  470.         while LeftButtonDown and AmmoInClip > 0 and not Reloading do
  471.             if Spread and not DecreasedAimLastShot then
  472.                 Spread = math.min(MaxSpread, Spread + AimInaccuracyStepAmount)
  473.                 UpdateCrosshair(Spread)
  474.             end
  475.             DecreasedAimLastShot = not DecreasedAimLastShot
  476.             if Handle:FindFirstChild('FireSound') then
  477.                 Handle.FireSound:Play()
  478.                 Handle.Flash.Enabled = true
  479.             end
  480.             if MyMouse then
  481.                 local targetPoint = MyMouse.Hit.p
  482.                 local shootDirection = (targetPoint - Handle.Position).unit
  483.                 -- Adjust the shoot direction randomly off by a little bit to account for recoil
  484.                 shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
  485.                                                                 (0.5 - math.random()) * 2 * Spread,
  486.                                                                 (0.5 - math.random()) * 2 * Spread) * shootDirection
  487.                 local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
  488.                 local bullet
  489.                 -- Create a bullet here
  490.                 if hitObject then
  491.                     bullet = CreateBullet(bulletPos)
  492.                 end
  493.                 if hitObject and hitObject.Parent then
  494.                     local hitHumanoid = hitObject.Parent:FindFirstChild("Humanoid")
  495.                     if hitHumanoid then
  496.                         local hitPlayer = game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)
  497.                         if MyPlayer.Neutral or hitPlayer then
  498.                             TagHumanoid(hitHumanoid, MyPlayer)
  499.                             hitHumanoid:TakeDamage(Damage)
  500.                             if bullet then
  501.                                 bullet:Destroy()
  502.                                 bullet = nil
  503.                                 --bullet.Transparency = 1
  504.                             end
  505.                             Spawn(UpdateTargetHit)
  506.                         end
  507.                     end
  508.                 end
  509.    
  510.                 AmmoInClip = AmmoInClip - 1
  511.                 UpdateAmmo(AmmoInClip)
  512.             end
  513.             wait(FireRate)
  514.         end
  515.         Handle.Flash.Enabled = false
  516.         IsShooting = false
  517.         if AmmoInClip == 0 then
  518.             Handle.Tick:Play()
  519.             WeaponGui.Reload.Visible = true
  520.         end
  521.         if RecoilTrack then
  522.             RecoilTrack:Stop()
  523.         end
  524.     end
  525. end
  526.  
  527. local TargetHits = 0
  528. function UpdateTargetHit()
  529.     TargetHits = TargetHits + 1
  530.     if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
  531.         WeaponGui.Crosshair.TargetHitImage.Visible = true
  532.     end
  533.     wait(0.5)
  534.     TargetHits = TargetHits - 1
  535.     if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
  536.         WeaponGui.Crosshair.TargetHitImage.Visible = false
  537.     end
  538. end
  539.  
  540. function UpdateCrosshair(value, mouse)
  541.     if WeaponGui then
  542.         local absoluteY = 650
  543.         WeaponGui.Crosshair:TweenSize(
  544.             UDim2.new(0, value * absoluteY * 2 + 23, 0, value * absoluteY * 2 + 23),
  545.             Enum.EasingDirection.Out,
  546.             Enum.EasingStyle.Linear,
  547.             0.33)
  548.     end
  549. end
  550.  
  551. function UpdateAmmo(value)
  552.     if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
  553.         WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
  554.         if value > 0 and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
  555.             WeaponGui.Crosshair.ReloadingLabel.Visible = false
  556.         end
  557.     end
  558.     if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
  559.         WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
  560.     end
  561. end
  562.  
  563.  
  564. function OnMouseDown()
  565.     LeftButtonDown = true
  566.     OnFire()
  567. end
  568.  
  569. function OnMouseUp()
  570.     LeftButtonDown = false
  571. end
  572.  
  573. function OnKeyDown(key)
  574.     if string.lower(key) == 'r' then
  575.         Reload()
  576.     end
  577. end
  578.  
  579.  
  580. function OnEquipped(mouse)
  581.     Handle.EquipSound:Play()
  582.     RecoilAnim = WaitForChild(Tool, 'Recoil')
  583.     FireSound  = WaitForChild(Handle, 'FireSound')
  584.  
  585.     MyCharacter = Tool.Parent
  586.     MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
  587.     MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
  588.     MyTorso = MyCharacter:FindFirstChild('Torso')
  589.     MyMouse = mouse
  590.     WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()
  591.     if WeaponGui and MyPlayer then
  592.         WeaponGui.Parent = MyPlayer.PlayerGui
  593.         UpdateAmmo(AmmoInClip)
  594.     end
  595.     if RecoilAnim then
  596.         RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
  597.     end
  598.  
  599.     if MyMouse then
  600.         -- Disable mouse icon
  601.         MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
  602.         MyMouse.Button1Down:connect(OnMouseDown)
  603.         MyMouse.Button1Up:connect(OnMouseUp)
  604.         MyMouse.KeyDown:connect(OnKeyDown)
  605.     end
  606. end
  607.  
  608.  
  609. -- Unequip logic here
  610. function OnUnequipped()
  611.     LeftButtonDown = false
  612.     Reloading = false
  613.     MyCharacter = nil
  614.     MyHumanoid = nil
  615.     MyTorso = nil
  616.     MyPlayer = nil
  617.     MyMouse = nil
  618.     if OnFireConnection then
  619.         OnFireConnection:disconnect()
  620.     end
  621.     if OnReloadConnection then
  622.         OnReloadConnection:disconnect()
  623.     end
  624.     if FlashHolder then
  625.         FlashHolder = nil
  626.     end
  627.     if WeaponGui then
  628.         WeaponGui.Parent = nil
  629.         WeaponGui = nil
  630.     end
  631.     if RecoilTrack then
  632.         RecoilTrack:Stop()
  633.     end
  634. end
  635.  
  636. local function SetReticleColor(color)
  637.     if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
  638.         for _, line in pairs(WeaponGui.Crosshair:GetChildren()) do
  639.             if line:IsA('Frame') then
  640.                 line.BorderColor3 = color
  641.             end
  642.         end
  643.     end
  644. end
  645.  
  646.  
  647. Tool.Equipped:connect(OnEquipped)
  648. Tool.Unequipped:connect(OnUnequipped)
  649.  
  650. while true do
  651.     wait(0.033)
  652.     if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and MyMouse then
  653.         WeaponGui.Crosshair.Position = UDim2.new(0, MyMouse.X, 0, MyMouse.Y)
  654.         SetReticleColor(NeutralReticleColor)
  655.  
  656.         local target = MyMouse.Target
  657.         if target and target.Parent then
  658.             local player = PlayersService:GetPlayerFromCharacter(target.Parent)
  659.             if player then
  660.                 if MyPlayer.Neutral or player.TeamColor ~= MyPlayer.TeamColor then
  661.                     SetReticleColor(EnemyReticleColor)
  662.                 else
  663.                     SetReticleColor(FriendlyReticleColor)
  664.                 end
  665.             end
  666.         end
  667.     end
  668.     if Spread and not IsShooting then
  669.         local currTime = time()
  670.         if currTime - LastSpreadUpdate > FireRate * 2 then
  671.             LastSpreadUpdate = currTime
  672.             Spread = math.max(MinSpread, Spread - AimInaccuracyStepAmount)
  673.             UpdateCrosshair(Spread, MyMouse)
  674.         end
  675.     end
  676. end
  677.  
  678. end,o26)
  679. end))
  680. o27.Name = "Welding"
  681. o27.Parent = o1
  682. table.insert(cors,coroutine.create(function()
  683. wait()
  684. runDummyScript(function()
  685. function Weld(x,y)
  686.     local W = Instance.new("Weld")
  687.     W.Part0 = x
  688.     W.Part1 = y
  689.     local CJ = CFrame.new(x.Position)
  690.     local C0 = x.CFrame:inverse()*CJ
  691.     local C1 = y.CFrame:inverse()*CJ
  692.     W.C0 = C0
  693.     W.C1 = C1
  694.     W.Parent = x
  695. end
  696.  
  697. function Get(A)
  698.     if A.className == "MeshPart" then
  699.         Weld(o2, A)
  700.         A.Anchored = false
  701.     else
  702.         local C = A:GetChildren()
  703.         for i=1, #C do
  704.         Get(C[i])
  705.         end
  706.     end
  707. end
  708.  
  709. function Finale()
  710.     Get(o1)
  711. end
  712.  
  713. o1.Equipped:connect(Finale)
  714. o1.Unequipped:connect(Finale)
  715. Finale()
  716.  
  717. end,o27)
  718. end))
  719. mas.Parent = workspace
  720. mas:MakeJoints()
  721. local mas1 = mas:GetChildren()
  722. for i=1,#mas1 do
  723.     mas1[i].Parent = workspace
  724.     ypcall(function() mas1[i]:MakeJoints() end)
  725. end
  726. mas:Destroy()
  727. for i=1,#cors do
  728. coroutine.resume(cors[i])
  729. end
Add Comment
Please, Sign In to add comment