Advertisement
Guest User

pistol

a guest
Jan 3rd, 2020
4,959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.10 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Script1 = Instance.new("Script")
  21. LocalScript2 = Instance.new("LocalScript")
  22. Part3 = Instance.new("Part")
  23. SpecialMesh4 = Instance.new("SpecialMesh")
  24. Sound5 = Instance.new("Sound")
  25. Sound6 = Instance.new("Sound")
  26. Vector3Value7 = Instance.new("Vector3Value")
  27. IntValue8 = Instance.new("IntValue")
  28. BoolValue9 = Instance.new("BoolValue")
  29. IntValue10 = Instance.new("IntValue")
  30. BoolValue11 = Instance.new("BoolValue")
  31. Animation12 = Instance.new("Animation")
  32. BoolValue13 = Instance.new("BoolValue")
  33. ScreenGui14 = Instance.new("ScreenGui")
  34. Frame15 = Instance.new("Frame")
  35. Frame16 = Instance.new("Frame")
  36. Frame17 = Instance.new("Frame")
  37. ImageLabel18 = Instance.new("ImageLabel")
  38. ImageLabel19 = Instance.new("ImageLabel")
  39. Frame20 = Instance.new("Frame")
  40. ImageLabel21 = Instance.new("ImageLabel")
  41. ImageLabel22 = Instance.new("ImageLabel")
  42. ImageLabel23 = Instance.new("ImageLabel")
  43. Frame24 = Instance.new("Frame")
  44. Frame25 = Instance.new("Frame")
  45. ImageLabel26 = Instance.new("ImageLabel")
  46. ImageLabel27 = Instance.new("ImageLabel")
  47. Frame28 = Instance.new("Frame")
  48. ImageLabel29 = Instance.new("ImageLabel")
  49. ImageLabel30 = Instance.new("ImageLabel")
  50. Animation31 = Instance.new("Animation")
  51. Animation32 = Instance.new("Animation")
  52. SpecialMesh33 = Instance.new("SpecialMesh")
  53. Script34 = Instance.new("Script")
  54. RemoteEvent35 = Instance.new("RemoteEvent")
  55. RemoteEvent36 = Instance.new("RemoteEvent")
  56. Camera37 = Instance.new("Camera")
  57. Tool0.Name = "Luger"
  58. Tool0.Parent = mas
  59. Tool0.TextureId = "http://www.roblox.com/asset/?id=95356596"
  60. Tool0.Grip = CFrame.new(0.0939477235, -0.206212491, 0.560361266, 0.837946475, -0.0272410847, 0.545072019, -0.0256806612, 0.995679021, 0.0892403126, -0.545147896, -0.0887763947, 0.833626151)
  61. Tool0.GripForward = Vector3.new(-0.545072019, -0.0892403126, -0.833626151)
  62. Tool0.GripPos = Vector3.new(0.0939477235, -0.206212491, 0.560361266)
  63. Tool0.GripRight = Vector3.new(0.837946475, -0.0256806612, -0.545147896)
  64. Tool0.GripUp = Vector3.new(-0.0272410847, 0.995679021, -0.0887763947)
  65. Tool0.ToolTip = "Luger Pistol"
  66. Script1.Name = "Firescript"
  67. Script1.Parent = Tool0
  68. table.insert(cors,sandbox(Script1,function()
  69. -- Made by Stickmasterluke
  70. -- edited by fusroblox
  71. local GoreOn=true
  72. function WaitForChild(parent,child)
  73. while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end
  74. return parent[child]
  75. end
  76. local GLib = require(206209239)
  77.  
  78. local GunObject = {
  79. Tool = script.Parent,
  80. Handle = WaitForChild(script.Parent,'Handle'),
  81. check = true,
  82.  
  83. GunDamage = 20, -- Base output damage per shot.
  84. FireRate = .2, -- How often the weapon can fire.
  85. Automatic = false, -- hold down to continue firing
  86. Range = 250, -- Max distance that the weapon can fire.
  87. Spread = 1, -- The bigger the spread, the more inaccurate the shots will be.
  88. ClipSize = 8, -- Shots in a clip
  89. ReloadTime = 3, -- Time it takes to reload the tool.
  90. StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool.
  91. SegmentLength = 40, -- How long the shot segments are, or the speed of the shot.
  92. FadeDelayTime = 1/60,
  93.  
  94.  
  95. BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U
  96. Rate = 1/30,
  97. --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")}
  98. Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")},
  99. FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"},
  100.  
  101. Reloading = false,
  102. Debris = game:GetService("Debris"),
  103. Ammo,
  104. Clips,
  105. LaserObj,
  106. SparkEffect,
  107. ShellPart,
  108. --tool children
  109. DownVal=WaitForChild(script.Parent, 'Down'),
  110. AimVal=WaitForChild(script.Parent, 'Aim'),
  111. ReloadingVal=WaitForChild(script.Parent, 'Reloading'),
  112. DoFireAni = WaitForChild(script.Parent,'DoFireAni'),
  113.  
  114. --handlechildren
  115. Fire,
  116.  
  117. }
  118.  
  119. --[[Member functions]]
  120.  
  121. function GunObject:Initialize()
  122.  
  123. self.Fire=WaitForChild(self.Handle, 'Fire')
  124.  
  125. self.Ammo = self.Tool:FindFirstChild("Ammo")
  126. if self.Ammo ~= nil then
  127. self.Ammo.Value = self.ClipSize
  128. end
  129. self.Clips = self.Tool:FindFirstChild("Clips")
  130. if self.Clips ~= nil then
  131. self.Clips.Value = self.StartingClips
  132. end
  133. self.Tool.Equipped:connect(function()
  134. self.Tool.Handle.Fire:Stop()
  135. self.Tool.Handle.Reload:Stop()
  136. end)
  137. self.Tool.Unequipped:connect(function()
  138. self.Tool.Handle.Fire:Stop()
  139. self.Tool.Handle.Reload:Stop()
  140. end)
  141. self.LaserObj = Instance.new("Part")
  142. self.LaserObj.Name = "Bullet"
  143. self.LaserObj.Anchored = true
  144. self.LaserObj.CanCollide = false
  145. self.LaserObj.Shape = "Block"
  146. self.LaserObj.formFactor = "Custom"
  147. self.LaserObj.Material = Enum.Material.Plastic
  148. self.LaserObj.Locked = true
  149. self.LaserObj.TopSurface = 0
  150. self.LaserObj.BottomSurface = 0
  151. --local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone()
  152. --tshellmesh.Scale=Vector3.new(4,4,4)
  153. --tshellmesh.Parent=self.LaserObj
  154.  
  155. local tSparkEffect = Instance.new("Part")
  156. tSparkEffect.Name = "Effect"
  157. tSparkEffect.Anchored = false
  158. tSparkEffect.CanCollide = false
  159. tSparkEffect.Shape = "Block"
  160. tSparkEffect.formFactor = "Custom"
  161. tSparkEffect.Material = Enum.Material.Plastic
  162. tSparkEffect.Locked = true
  163. tSparkEffect.TopSurface = 0
  164. tSparkEffect.BottomSurface = 0
  165. self.SparkEffect=tSparkEffect
  166.  
  167. local tshell = Instance.new('Part')
  168. tshell.Name='effect'
  169. tshell.FormFactor='Custom'
  170. tshell.Size=Vector3.new(1, 0.4, 0.33)
  171. tshell.BrickColor=BrickColor.new('Bright yellow')
  172. tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone()
  173. tshellmesh.Parent=tshell
  174. self.ShellPart = tshell
  175.  
  176. self.DownVal.Changed:connect(function()
  177. while self.DownVal.Value and self.check and not self.Reloading do
  178. self.check = false
  179. local humanoid = self.Tool.Parent:FindFirstChild("Humanoid")
  180. local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent)
  181. if humanoid ~= nil and plr1 ~= nil then
  182. if humanoid.Health > 0 then
  183. local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p
  184. delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end)
  185. else
  186. self.check = true
  187. break
  188. end
  189. else
  190. self.check = true
  191. break
  192. end
  193. wait(self.FireRate)
  194. self.check = true
  195. if not self.Automatic then
  196. break
  197. end
  198. end
  199. end)
  200.  
  201. self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end)
  202.  
  203. end
  204.  
  205.  
  206.  
  207. function GunObject:Reload()
  208. self.Reloading = true
  209. self.ReloadingVal.Value = true
  210. if self.Clips ~= nil then
  211. if self.Clips.Value > 0 then
  212. self.Clips.Value = Clips.Value - 1
  213. else
  214. self.Reloading = false
  215. self.ReloadingVal.Value = false
  216. return
  217. end
  218. end
  219. self.Tool.Handle.Reload:Play()
  220. for i = 1, self.ClipSize do
  221. wait(self.ReloadTime/self.ClipSize)
  222. self.Ammo.Value = i
  223. end
  224. self.Reloading = false
  225. self.Tool.Reloading.Value = false
  226. end
  227.  
  228.  
  229.  
  230. function GunObject:SpawnShell()
  231. local tshell=self.ShellPart:Clone()
  232. tshell.CFrame=self.Handle.CFrame
  233. tshell.Parent=Workspace
  234. game.Debris:AddItem(tshell,2)
  235. end
  236.  
  237. function KnockOffHats(tchar)
  238. for _,i in pairs(tchar:GetChildren()) do
  239. if i:IsA('Hat') then
  240. i.Parent=game.Workspace
  241. end
  242. end
  243. end
  244.  
  245. function KnockOffTool(tchar)
  246. for _,i in pairs(tchar:GetChildren()) do
  247. if i:IsA('Tool') then
  248. i.Parent=game.Workspace
  249. end
  250. end
  251. end
  252.  
  253. function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay)
  254. if self.Ammo.Value <=0 then return end
  255. self.Ammo.Value = self.Ammo.Value - 1
  256. self:SpawnShell()
  257. self.Fire.Pitch = (math.random() * .5) + .75
  258. self.Fire:Play()
  259. self.DoFireAni.Value = not self.DoFireAni.Value
  260. print(self.Fire.Pitch)
  261. local boltdist = self.Range
  262. local clickdist = (boltstart - targetpos).magnitude
  263. local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100))
  264. local boltvec = (targetpos - boltstart).unit
  265. local totalsegments = math.ceil(boltdist/SegmentLength)
  266. local lastpos = boltstart
  267. for i = 1, totalsegments do
  268. local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments))))
  269. local segvec = (newpos - lastpos).unit
  270. local boltlength = (newpos - lastpos).magnitude
  271. local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false)
  272. DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj)
  273. if bolthit ~= nil then
  274. local h = bolthit.Parent:FindFirstChild("Humanoid")
  275. if h ~= nil then
  276. local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent)
  277. if plr ~= nil then
  278. local creator = Instance.new("ObjectValue")
  279. creator.Name = "creator"
  280. creator.Value = plr
  281. creator.Parent = h
  282. end
  283. if hit.Parent:FindFirstChild("BlockShot") then
  284. hit.Parent:FindFirstChild("BlockShot"):Fire(newpos)
  285. delay(0, function() self:HitEffect(endpos, bolthit,5) end)
  286. else
  287. if(hit.Name=='Head') then
  288. KnockOffHats(hit.Parent)
  289. elseif hit.Name=='Left Leg' or hit.Name=='Right Leg' then
  290. h.WalkSpeed=h.WalkSpeed/1.5
  291. elseif hit.Name=='Left Arm' or hit.Name=='Right Arm' then
  292. KnockOffTool(hit.Parent)
  293. end
  294. if GoreOn then delay(0,function() self:HitEffect(endpos, bolthit,20) end) end
  295. if GLib.IsTeammate(GLib.GetPlayerFromPart(script), GLib.GetPlayerFromPart(h))~=true then
  296. GLib.TagHumanoid(GLib.GetPlayerFromPart(script), h, 1)
  297. h:TakeDamage(damage)
  298. end
  299. end
  300. else
  301. delay(0, function() self:HitEffect(endpos, bolthit,5) end)
  302. end
  303. break
  304. end
  305. lastpos = endpos
  306. wait(Rate)
  307. end
  308.  
  309. if self.Ammo.Value < 1 then
  310. self:Reload()
  311. end
  312.  
  313. end
  314.  
  315.  
  316.  
  317. function GunObject:MakeSpark(pos,part)
  318. local effect=self.SparkEffect:Clone()
  319. effect.BrickColor = part.BrickColor
  320. effect.Material = part.Material
  321. effect.Transparency = part.Transparency
  322. effect.Reflectance = part.Reflectance
  323. effect.CFrame = CFrame.new(pos)
  324. effect.Parent = game.Workspace
  325. local effectVel = Instance.new("BodyVelocity")
  326. effectVel.maxForce = Vector3.new(99999, 99999, 99999)
  327. effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)))
  328. effectVel.Parent = effect
  329. effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30)
  330. wait()
  331. effectVel:Destroy()
  332. local effecttime = .5
  333. game.Debris:AddItem(effect, effecttime * 2)
  334. local startTime = time()
  335. while time() - startTime < effecttime do
  336. if effect ~= nil then
  337. effect.Transparency = (time() - startTime)/effecttime
  338. end
  339. wait()
  340. end
  341. if effect ~= nil then
  342. effect.Parent = nil
  343. end
  344. end
  345.  
  346. function GunObject:HitEffect(pos,part,numSparks)
  347. for i = 0, numSparks, 1 do
  348. spawn(function() self:MakeSpark(pos,part) end)
  349. end
  350.  
  351. end
  352.  
  353. --[[/Member functions]]
  354.  
  355.  
  356. --[[Static functions]]
  357.  
  358. function Round(number, decimal)
  359. decimal = decimal or 0
  360. local mult = 10^decimal
  361. return math.floor(number * mult + .5)/mult
  362. end
  363.  
  364. function SigNum(num)
  365. if num == 0 then return 1 end
  366. return math.abs(num)/num
  367. end
  368.  
  369. --this is a little bad, but shouldn't really be part of the 'class' of the gun
  370. local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,}
  371. function CheckIntangible(hitObj)
  372. print(hitObj.Name)
  373. return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1
  374. end
  375.  
  376. function CastRay(startpos, vec, length, ignore, delayifhit)
  377. if length > 999 then
  378. length = 999
  379. end
  380. hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore)
  381. if hit ~= nil then
  382. if CheckIntangible(hit) then
  383. if delayifhit then
  384. wait()
  385. end
  386. hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit)
  387. end
  388. end
  389. return hit, endpos2
  390. end
  391.  
  392. function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart)
  393. local dis = 2 --(beamstart - beamend).magnitude
  394. local tlaser=templatePart:Clone()
  395. tlaser.BrickColor = clr
  396. tlaser.Size = Vector3.new(.12, .12, dis + .2)
  397. tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2)
  398. tlaser.Parent = game.Workspace
  399. game.Debris:AddItem(tlaser, fadedelay)
  400. end
  401.  
  402. --[[/Static functions]]
  403.  
  404.  
  405. GunObject:Initialize()
  406. end))
  407. LocalScript2.Parent = Tool0
  408. table.insert(cors,sandbox(LocalScript2,function()
  409. local equipped = false
  410. local setIconCon
  411. local Players = game:GetService'Players'
  412. local reloadCounter = 0
  413. Cursors = {
  414. "http://www.roblox.com/asset/?id=94154683", -- black
  415. "http://www.roblox.com/asset/?id= 94154829", -- red
  416. "http://www.roblox.com/asset/?id=94155503",
  417. "http://www.roblox.com/asset/?id=94155569"
  418. }
  419.  
  420. local getCharacterFromPart = function(part)
  421. local current = part
  422. local character = nil
  423. local humanoid = nil
  424. while true do
  425. for i, child in next, current:GetChildren() do
  426. if child:IsA'Humanoid' then
  427. character = current
  428. humanoid = child
  429. break
  430. end
  431. end
  432.  
  433. if character then
  434. break
  435. else
  436. current = current.Parent
  437.  
  438. if not current or current == game then
  439. break
  440. end
  441. end
  442. end
  443.  
  444. return character, character and Players:GetPlayerFromCharacter(character), humanoid
  445. end
  446.  
  447. script.Parent.Equipped:connect(function(mouse)
  448. equipped = true
  449. mouse.Button1Down:connect(function() script.Parent.Input:FireServer('Mouse1', true, mouse.Hit.p, mouse.Target) end)
  450. mouse.Button1Up:connect(function() script.Parent.Input:FireServer('Mouse1', false, mouse.Hit.p) end)
  451. mouse.KeyDown:connect(function(key) script.Parent.Input:FireServer('Key', true, key) end)
  452. mouse.KeyUp:connect(function(key) script.Parent.Input:FireServer('Key', false, key) end)
  453.  
  454. setIconCon = script.Parent.SetIcon.OnClientEvent:connect(function(icon)
  455. mouse.Icon = icon
  456. end)
  457.  
  458. spawn(function()
  459. local reloadCounter = 0
  460. while equipped do
  461. if script.Parent.Reloading.Value then
  462. reloadCounter=reloadCounter+1
  463. if reloadCounter%20<10 then
  464. mouse.Icon = Cursors[3]
  465. else
  466. mouse.Icon = Cursors[4]
  467. end
  468. elseif mouse.Target and getCharacterFromPart(mouse.Target) then
  469. mouse.Icon = Cursors[2]
  470. else
  471. mouse.Icon = Cursors[1]
  472. end
  473.  
  474. game:GetService'RunService'.RenderStepped:wait()
  475. end
  476. end)
  477.  
  478. CAS,UIS = game:GetService'ContextActionService',game:GetService'UserInputService'
  479. if UIS.TouchEnabled then
  480. CAS:BindActionToInputTypes(
  481. 'Luger_Reload',
  482. function()
  483. script.Parent.Input:FireServer('Key', true, 'r')
  484. end,
  485. true,
  486. ''
  487. )
  488. CAS:SetTitle('Luger_Reload', 'Reload')
  489. end
  490. while equipped do
  491. script.Parent.Input:FireServer('MouseMove', mouse.Hit.p, mouse.Target)
  492. wait(1/20)
  493. end
  494. end)
  495. script.Parent.Unequipped:connect(function()
  496. equipped = false
  497.  
  498. if setIconCon then setIconCon:disconnect() end
  499.  
  500. if CAS then CAS:UnbindAction('Luger_Reload') end
  501. end)
  502. end))
  503. Part3.Name = "Handle"
  504. Part3.Parent = Tool0
  505. Part3.CFrame = CFrame.new(-136.330017, 15.9392357, -17.2600117, 0, 0, -1, 0, 1, -0, 1, 0, -0)
  506. Part3.Orientation = Vector3.new(0, -90, 0)
  507. Part3.Position = Vector3.new(-136.330017, 15.9392357, -17.2600117)
  508. Part3.Rotation = Vector3.new(0, -90, 0)
  509. Part3.Color = Color3.new(0, 0.560784, 0.611765)
  510. Part3.Size = Vector3.new(0.510000467, 1.18000245, 1.34999704)
  511. Part3.BrickColor = BrickColor.new("Bright bluish green")
  512. Part3.Locked = true
  513. Part3.Material = Enum.Material.Metal
  514. Part3.brickColor = BrickColor.new("Bright bluish green")
  515. Part3.FormFactor = Enum.FormFactor.Custom
  516. Part3.formFactor = Enum.FormFactor.Custom
  517. SpecialMesh4.Parent = Part3
  518. SpecialMesh4.MeshId = "http://www.roblox.com/asset/?id=95356090"
  519. SpecialMesh4.Scale = Vector3.new(1.79999995, 1.79999995, 1.79999995)
  520. SpecialMesh4.TextureId = "http://www.roblox.com/asset/?id=95387789"
  521. SpecialMesh4.MeshType = Enum.MeshType.FileMesh
  522. Sound5.Name = "Fire"
  523. Sound5.Parent = Part3
  524. Sound5.Pitch = 0.82116913795471
  525. Sound5.PlaybackSpeed = 0.82116913795471
  526. Sound5.SoundId = "http://www.roblox.com/asset/?id=95309366"
  527. Sound5.Volume = 1
  528. Sound6.Name = "Reload"
  529. Sound6.Parent = Part3
  530. Sound6.SoundId = "http://www.roblox.com/asset/?id=95309699"
  531. Sound6.Volume = 1
  532. Vector3Value7.Name = "Aim"
  533. Vector3Value7.Parent = Tool0
  534. Vector3Value7.Value = Vector3.new(7370.47461, -428.252258, -6819.59961)
  535. IntValue8.Name = "Ammo"
  536. IntValue8.Parent = Tool0
  537. IntValue8.Value = 8
  538. BoolValue9.Name = "Down"
  539. BoolValue9.Parent = Tool0
  540. IntValue10.Name = "NoClips"
  541. IntValue10.Parent = Tool0
  542. BoolValue11.Name = "Reloading"
  543. BoolValue11.Parent = Tool0
  544. Animation12.Name = "FireAni"
  545. Animation12.Parent = Tool0
  546. Animation12.AnimationId = "http://www.roblox.com/Asset?ID=95383980"
  547. BoolValue13.Name = "DoFireAni"
  548. BoolValue13.Parent = Tool0
  549. ScreenGui14.Name = "AmmoHud"
  550. ScreenGui14.Parent = Tool0
  551. Frame15.Name = "Bar"
  552. Frame15.Parent = ScreenGui14
  553. Frame15.Position = UDim2.new(1, -200, 1, -170)
  554. Frame15.Size = UDim2.new(0, 200, 0, 60)
  555. Frame15.BackgroundTransparency = 1
  556. Frame15.ClipsDescendants = true
  557. Frame16.Name = "AmmoLeft"
  558. Frame16.Parent = Frame15
  559. Frame16.Position = UDim2.new(0, 10, 0, 5)
  560. Frame16.Size = UDim2.new(0, 65, 0, 50)
  561. Frame16.BackgroundTransparency = 1
  562. Frame17.Name = "1"
  563. Frame17.Parent = Frame16
  564. Frame17.Size = UDim2.new(0, 30, 0, 40)
  565. Frame17.BackgroundTransparency = 1
  566. ImageLabel18.Parent = Frame17
  567. ImageLabel18.Size = UDim2.new(1, 0, 1, 0)
  568. ImageLabel18.BackgroundTransparency = 1
  569. ImageLabel18.ZIndex = 2
  570. ImageLabel18.Image = "http://www.roblox.com/asset/?id=94130434"
  571. ImageLabel19.Name = "digit"
  572. ImageLabel19.Parent = Frame17
  573. ImageLabel19.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0)
  574. ImageLabel19.Size = UDim2.new(0.899999976, 0, 0.899999976, 0)
  575. ImageLabel19.BackgroundTransparency = 1
  576. ImageLabel19.ZIndex = 2
  577. ImageLabel19.Image = "http://www.roblox.com/asset/?id=94099941"
  578. Frame20.Name = "2"
  579. Frame20.Parent = Frame16
  580. Frame20.Position = UDim2.new(1, -30, 0, 0)
  581. Frame20.Size = UDim2.new(0, 30, 0, 40)
  582. Frame20.BackgroundTransparency = 1
  583. ImageLabel21.Parent = Frame20
  584. ImageLabel21.Size = UDim2.new(1, 0, 1, 0)
  585. ImageLabel21.BackgroundTransparency = 1
  586. ImageLabel21.ZIndex = 2
  587. ImageLabel21.Image = "http://www.roblox.com/asset/?id=94130434"
  588. ImageLabel22.Name = "digit"
  589. ImageLabel22.Parent = Frame20
  590. ImageLabel22.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0)
  591. ImageLabel22.Size = UDim2.new(0.899999976, 0, 0.899999976, 0)
  592. ImageLabel22.BackgroundTransparency = 1
  593. ImageLabel22.ZIndex = 2
  594. ImageLabel22.Image = "http://www.roblox.com/asset/?id=94099941"
  595. ImageLabel23.Name = "slash"
  596. ImageLabel23.Parent = Frame15
  597. ImageLabel23.Position = UDim2.new(0.5, -20, 0, 5)
  598. ImageLabel23.Size = UDim2.new(0, 30, 0, 40)
  599. ImageLabel23.BackgroundTransparency = 1
  600. ImageLabel23.ZIndex = 2
  601. ImageLabel23.Image = "http://www.roblox.com/asset/?id=94100300"
  602. Frame24.Name = "TotalAmmo"
  603. Frame24.Parent = Frame15
  604. Frame24.Position = UDim2.new(0.5, 10, 0, 5)
  605. Frame24.Size = UDim2.new(0, 65, 0, 50)
  606. Frame24.BackgroundTransparency = 1
  607. Frame25.Name = "1"
  608. Frame25.Parent = Frame24
  609. Frame25.Size = UDim2.new(0, 30, 0, 40)
  610. Frame25.BackgroundTransparency = 1
  611. Frame25.ClipsDescendants = true
  612. ImageLabel26.Parent = Frame25
  613. ImageLabel26.Size = UDim2.new(1, 0, 1, 0)
  614. ImageLabel26.BackgroundTransparency = 1
  615. ImageLabel26.ZIndex = 2
  616. ImageLabel26.Image = "http://www.roblox.com/asset/?id=94130434"
  617. ImageLabel27.Name = "digit"
  618. ImageLabel27.Parent = Frame25
  619. ImageLabel27.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0)
  620. ImageLabel27.Size = UDim2.new(0.899999976, 0, 0.899999976, 0)
  621. ImageLabel27.BackgroundTransparency = 1
  622. ImageLabel27.ZIndex = 2
  623. ImageLabel27.Image = "http://www.roblox.com/asset/?id=94099941"
  624. Frame28.Name = "2"
  625. Frame28.Parent = Frame24
  626. Frame28.Position = UDim2.new(1, -30, 0, 0)
  627. Frame28.Size = UDim2.new(0, 30, 0, 40)
  628. Frame28.BackgroundTransparency = 1
  629. ImageLabel29.Parent = Frame28
  630. ImageLabel29.Size = UDim2.new(1, 0, 1, 0)
  631. ImageLabel29.BackgroundTransparency = 1
  632. ImageLabel29.ZIndex = 2
  633. ImageLabel29.Image = "http://www.roblox.com/asset/?id=94130434"
  634. ImageLabel30.Name = "digit"
  635. ImageLabel30.Parent = Frame28
  636. ImageLabel30.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0)
  637. ImageLabel30.Size = UDim2.new(0.899999976, 0, 0.899999976, 0)
  638. ImageLabel30.BackgroundTransparency = 1
  639. ImageLabel30.ZIndex = 2
  640. ImageLabel30.Image = "http://www.roblox.com/asset/?id=94099941"
  641. Animation31.Name = "idle"
  642. Animation31.Parent = Tool0
  643. Animation31.AnimationId = "http://www.roblox.com/Asset?ID=95383474"
  644. Animation32.Name = "Reload"
  645. Animation32.Parent = Tool0
  646. Animation32.AnimationId = "http://www.roblox.com/Asset?ID=95384819"
  647. SpecialMesh33.Name = "BulletMesh"
  648. SpecialMesh33.Parent = Tool0
  649. SpecialMesh33.MeshId = "http://www.roblox.com/asset/?id=95387759"
  650. SpecialMesh33.Scale = Vector3.new(3, 3, 3)
  651. SpecialMesh33.TextureId = "http://www.roblox.com/asset/?id=95387789"
  652. SpecialMesh33.MeshType = Enum.MeshType.FileMesh
  653. Script34.Parent = Tool0
  654. table.insert(cors,sandbox(Script34,function()
  655. -- Made by Stickmasterluke
  656. -- edited by fusroblox
  657. --[[
  658. Fixed by ArceusInator 2/25/2015
  659. - Now works with FE
  660. - Should no longer lock up occasionally when you shoot an NPC
  661. - Gibs are now properly colored + Characters now spew gory gibs just like other bricks
  662. - No longer teamkills
  663. - Now registers KOs to the site
  664. --]]
  665.  
  666. function WaitForChild(obj, name)
  667. while not obj:FindFirstChild(name) do
  668. wait()
  669. --print("1waiting for " .. name)
  670. end
  671. return obj:FindFirstChild(name)
  672. end
  673.  
  674. local function FindCharacterAncestor(subject)
  675. if subject and subject ~= Workspace then
  676. if subject:FindFirstChild('Humanoid') then
  677. return subject
  678. else
  679. return FindCharacterAncestor(subject.Parent)
  680. end
  681. end
  682. return nil
  683. end
  684.  
  685. local Tool = script.Parent
  686.  
  687. local MouseObj = {
  688. Hit = CFrame.new()
  689. }
  690. local GunObj ={
  691. Reloading = "http://www.roblox.com/asset/?id=94155503",
  692.  
  693. Cursors = {
  694. "http://www.roblox.com/asset/?id=94154683", -- black
  695. "http://www.roblox.com/asset/?id= 94154829", -- red
  696. "http://www.roblox.com/asset/?id=94155503",
  697. "http://www.roblox.com/asset/?id=94155569"
  698. },
  699.  
  700. ClipSize = 8,
  701. Equipped = false,
  702.  
  703. Player = nil,
  704. Ammo = WaitForChild(script.Parent,"Ammo"),
  705. Clips,
  706. Gui = WaitForChild(Tool,"AmmoHud"),
  707. NumberImages={},
  708. IdleAni,
  709. MyMouse
  710.  
  711. }
  712.  
  713. local ChestWeld
  714. Tool.Equipped:connect(function() GunObj:OnEquipped() end)
  715. local initialized=false
  716.  
  717. function GunObj:Initialize()
  718. if initialized then return end
  719. initialized=true
  720. self.Ammo.Changed:connect(function()self:UpdateGui()end)
  721.  
  722. WaitForChild(Tool, "Reloading")
  723. print('got to connections!!!!! ')
  724. Tool.Reloading.Changed:connect(function() self:UpdateGui() end)
  725. Tool.Unequipped:connect(function() self:OnUnequipped() end)
  726.  
  727. Tool.DoFireAni.Changed:connect(PlayFireAni)
  728. self.NumberImages['0']=94105090
  729. self.NumberImages['1']=94099941
  730. self.NumberImages['2']=94105282
  731. self.NumberImages['3']=94105353
  732. self.NumberImages['4']=94105393
  733. self.NumberImages['5']=94105402
  734. self.NumberImages['6']=94105413
  735. self.NumberImages['7']=94105478
  736. self.NumberImages['8']=94105560
  737. self.NumberImages['9']=94105576
  738.  
  739. local bar=WaitForChild(self.Gui,'Bar')
  740. self:UpdateNumbers(self.ClipSize..'', WaitForChild(bar,'TotalAmmo'))
  741. end
  742.  
  743. function GunObj:UpdateNumbers(data,frame)
  744. if string.len(data)==0 then
  745. data= '0'..data
  746. end
  747. if string.len(data)==1 then
  748. data= '0'..data
  749. end
  750.  
  751. local digit=WaitForChild(WaitForChild(frame,'1'),'digit')
  752. if digit.Image ~='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,1,1)] then
  753. local ndigit=digit:Clone()
  754. ndigit.Position=UDim2.new(ndigit.Position.X.Scale,ndigit.Position.X.Offset,ndigit.Position.Y.Scale,ndigit.Position.Y.Offset-65)
  755. ndigit.Image='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,1,1)]
  756. ndigit.Parent=digit.Parent
  757. ndigit:TweenPosition(digit.Position, "Out", "Quad", .1)
  758. digit.Name='oldDigit'
  759. digit:TweenPosition(UDim2.new(digit.Position.X.Scale,digit.Position.X.Offset,digit.Position.Y.Scale,digit.Position.Y.Offset+65), "Out", "Quad", .25)
  760. game.Debris:AddItem(digit,1)
  761. end
  762. digit=WaitForChild(WaitForChild(frame,'2'),'digit')
  763. if digit.Image ~='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,2,2)] then
  764. ndigit=digit:Clone()
  765. ndigit.Position=UDim2.new(ndigit.Position.X.Scale,ndigit.Position.X.Offset,ndigit.Position.Y.Scale,ndigit.Position.Y.Offset-65)
  766. ndigit.Image='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,2,2)]
  767. ndigit.Parent=digit.Parent
  768. ndigit:TweenPosition(UDim2.new(digit.Position.X.Scale,digit.Position.X.Offset,digit.Position.Y.Scale,0), "Out", "Quad", .25)
  769. digit.Name='oldDigit'
  770. digit:TweenPosition(UDim2.new(digit.Position.X.Scale,digit.Position.X.Offset,digit.Position.Y.Scale,digit.Position.Y.Offset+65), "Out", "Quad", .25)
  771. game.Debris:AddItem(digit,1)
  772. end
  773. end
  774.  
  775. function GunObj:UpdateGui()
  776. if self.Equipped then
  777. local Player = GunObj.Player
  778. if Player ~= nil then
  779. if self.Ammo == nil then
  780. --self.Gui.Bar.GunLabel.Text ="Futuro Heavy Pistol"
  781. --self.Gui.Bar.AmmoLabel.Text = ""
  782. else
  783. --self.Gui.Bar.GunLabel.Text ="Futuro Heavy Pistol"
  784. --self.Gui.Bar.AmmoLabel.Text = tostring(self.Ammo.Value).."/"..tostring(self.ClipSize)
  785. self:UpdateNumbers(tostring(self.Ammo.Value),WaitForChild(self.Gui.Bar,'AmmoLeft'))
  786. end
  787. if Tool.Reloading.Value then
  788. --self.Gui.Bar.AmmoLabel.Text = "Reloading"
  789. end
  790. end
  791. end
  792. end
  793.  
  794. function GunObj:CursorUpdate()
  795. local reloadCounter=0
  796. while self.Equipped do
  797. wait(1/30)
  798. end
  799. end
  800.  
  801. local InReload=false
  802.  
  803. script.Parent.Input.OnServerEvent:connect(function(client, action, ...)
  804. if client.Character == script.Parent.Parent then
  805. if action == 'Mouse1' then
  806. local down, hit, target = ...
  807.  
  808. if down then
  809. if not Tool.Down.Value then
  810. Tool.Aim.Value = hit
  811. Tool.Down.Value = true
  812. while Tool.Down.Value do
  813. Tool.Aim.Value = hit
  814. wait()
  815. end
  816. end
  817. else
  818. Tool.Down.Value = false
  819. end
  820.  
  821. MouseObj.Hit, MouseObj.Target = hit, target
  822. elseif action == 'MouseMove' then
  823. MouseObj.Hit, MouseObj.Target = ...
  824. elseif action == 'Key' then
  825. local down, key = ...
  826.  
  827. if down then
  828. if key=='r' and not Tool.Reloading.Value and not Tool.Down.Value and GunObj.Ammo.Value ~=8 and GunObj.Ammo.Value ~=0 and not InReload then
  829. Tool.Reloading.Value=true
  830. end
  831. end
  832. end
  833. end
  834. end)
  835.  
  836. function GunObj:OnEquipped()
  837. self:Initialize()
  838. self.Equipped = true
  839. GunObj.Player = game:GetService'Players':GetPlayerFromCharacter(Tool.Parent)
  840. local Player = GunObj.Player
  841. if Player ~= nil then
  842. local humanoid=WaitForChild(Player.Character,'Humanoid')
  843. if not self.IdleAni then
  844. self.IdleAni = humanoid:LoadAnimation(WaitForChild(script.Parent,'idle'))
  845. self.IdleAni:Play()
  846. end
  847. local plrgui = WaitForChild(Player,"PlayerGui")
  848. self.Gui.Parent = plrgui
  849. Tool.Reloading.Changed:connect(function(val)
  850. if self.Equipped then
  851. if val then
  852. else
  853. end
  854. local Player = GunObj.Player
  855. if Player ~= nil then
  856. local gui = WaitForChild(Player.PlayerGui, "AmmoHud")
  857. local humanoid=WaitForChild(Player.Character,'Humanoid')
  858. self:UpdateGui()
  859. if Tool.Reloading.Value then
  860. --gui.Bar.AmmoLabel.Text = "Reloading"
  861. end
  862. end
  863. end
  864. end)
  865. self:UpdateGui()
  866. Spawn(function() self:CursorUpdate() end )
  867. end
  868. end
  869.  
  870. function GunObj:OnUnequipped()
  871. if self.IdleAni then
  872. self.IdleAni:Stop()
  873. self.IdleAni:Destroy()
  874. self.IdleAni=nil
  875. end
  876. self.Gui.Parent = Tool
  877. self.Equipped = false
  878. print('in unequipp')
  879. if ChestWeld then
  880. print('chestweldexists')
  881. ChestWeld:Destroy()
  882. end
  883. local Player = GunObj.Player
  884. if Player ~= nil then
  885. local gui = WaitForChild(Player.PlayerGui,"AmmoHud")
  886. --gui.Bar.GunLabel.Text = ""
  887. --gui.Bar.AmmoLabel.Text = ""
  888. end
  889. end
  890.  
  891. function PlayFireAni()
  892. wait(.1)
  893. local aniTrack = WaitForChild(Tool.Parent,"Humanoid"):LoadAnimation(Tool.FireAni)
  894. aniTrack:Play(0,1,1)
  895. end
  896.  
  897. local function weldBetween(a, b)
  898. local weld = Instance.new("Weld")
  899. weld.Part0 = a
  900. weld.Part1 = b
  901. weld.C0 = CFrame.new()
  902. weld.C1 = b.CFrame:inverse() * a.CFrame
  903. weld.Parent = a
  904. return weld;
  905. end
  906.  
  907.  
  908. function PlayReloadAni()
  909. InReload=true
  910. local aniTrack = WaitForChild(Tool.Parent,"Humanoid"):LoadAnimation(Tool.Reload)
  911. local torso=WaitForChild(Tool.Parent,'Torso')
  912. local oldWeld
  913. for _,i in pairs(WaitForChild(Tool.Parent,'Right Arm'):GetChildren()) do
  914. if i:IsA('Weld') and i.Part1==Tool.Handle then
  915. oldWeld=i
  916. end
  917. end
  918. if not oldWeld then
  919. print('What... no old weld!')
  920. return
  921. end
  922. ChestWeld= weldBetween(torso,Tool.Handle)
  923. oldWeld.Part1=nil
  924. aniTrack:Play(0,1,2)
  925. wait(4)
  926. oldWeld.Part1=Tool.Handle
  927. ChestWeld:Destroy()
  928. ChestWeld=nil
  929. InReload=false
  930. end
  931.  
  932. Tool.Reloading.Changed:connect(function() if Tool.Reloading.Value then PlayReloadAni() end end)
  933.  
  934. end))
  935. RemoteEvent35.Name = "Input"
  936. RemoteEvent35.Parent = Tool0
  937. RemoteEvent36.Name = "SetIcon"
  938. RemoteEvent36.Parent = Tool0
  939. Camera37.Name = "ThumbnailCamera"
  940. Camera37.Parent = Tool0
  941. Camera37.CFrame = CFrame.new(0.0709015876, 0.931264758, 2.04624701, 0.999557495, -0.00290121534, 0.0296054315, -0, 0.995232701, 0.0975288674, -0.0297472477, -0.0974857137, 0.994792223)
  942. Camera37.CoordinateFrame = CFrame.new(0.0709015876, 0.931264758, 2.04624701, 0.999557495, -0.00290121534, 0.0296054315, -0, 0.995232701, 0.0975288674, -0.0297472477, -0.0974857137, 0.994792223)
  943. Camera37.FieldOfView = 40
  944. Camera37.Focus = CFrame.new(0.00961841643, 0.72938025, -0.0129704475, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  945. Camera37.focus = CFrame.new(0.00961841643, 0.72938025, -0.0129704475, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  946. for i,v in pairs(mas:GetChildren()) do
  947. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  948. pcall(function() v:MakeJoints() end)
  949. end
  950. mas:Destroy()
  951. for i,v in pairs(cors) do
  952. spawn(function()
  953. pcall(v)
  954. end)
  955. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement