Advertisement
Guest User

Roblox fe script

a guest
Feb 21st, 2019
1,612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.90 KB | None | 0 0
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
  6.  
  7. --Converted with ttyyuu12345's model to script plugin v4
  8. local Player = game.Players.LocalPlayer
  9. local gear = workspace.Handgun
  10.  
  11. function sandbox(var,func)
  12. local env = getfenv(func)
  13. local newenv = setmetatable({},{
  14. __index = function(self,k)
  15. if k=="script" then
  16. return var
  17. else
  18. return env[k]
  19. end
  20. end,
  21. })
  22. setfenv(func,newenv)
  23. return func
  24. end
  25. cors = {}
  26. mas = Instance.new("Model",game:GetService("Lighting"))
  27. Camera0 = Instance.new("Camera")
  28. Part1 = Instance.new("Part")
  29. Tool2 = Instance.new("Tool")
  30. UnionOperation3 = Instance.new("UnionOperation")
  31. Sound4 = Instance.new("Sound")
  32. Sound5 = Instance.new("Sound")
  33. Sound6 = Instance.new("Sound")
  34. Sound7 = Instance.new("Sound")
  35. PointLight8 = Instance.new("PointLight")
  36. Smoke9 = Instance.new("Smoke")
  37. Sound10 = Instance.new("Sound")
  38. Sound11 = Instance.new("Sound")
  39. Animation12 = Instance.new("Animation")
  40. LocalScript13 = Instance.new("LocalScript")
  41. Script14 = Instance.new("Script")
  42. Part15 = Instance.new("Part")
  43. BillboardGui16 = Instance.new("BillboardGui")
  44. ImageLabel17 = Instance.new("ImageLabel")
  45. Script18 = Instance.new("Script")
  46. Animation19 = Instance.new("Animation")
  47. Script20 = Instance.new("Script")
  48. Camera21 = Instance.new("Camera")
  49. ScreenGui22 = Instance.new("ScreenGui")
  50. Frame23 = Instance.new("Frame")
  51. TextLabel24 = Instance.new("TextLabel")
  52. TextLabel25 = Instance.new("TextLabel")
  53. TextLabel26 = Instance.new("TextLabel")
  54. ImageLabel27 = Instance.new("ImageLabel")
  55. Frame28 = Instance.new("Frame")
  56. Frame29 = Instance.new("Frame")
  57. Frame30 = Instance.new("Frame")
  58. Frame31 = Instance.new("Frame")
  59. ImageLabel32 = Instance.new("ImageLabel")
  60. TextLabel33 = Instance.new("TextLabel")
  61. Frame34 = Instance.new("Frame")
  62. Sound35 = Instance.new("Sound")
  63. Script36 = Instance.new("Script")
  64. Script37 = Instance.new("Script")
  65. Camera0.Parent = mas
  66. Camera0.CFrame = CFrame.new(0.321689844, 18.2346153, 23.7645969, 0.98357147, -0.0819535926, 0.160844535, -0, 0.891008377, 0.453987002, -0.180519685, -0.446528673, 0.876370251)
  67. Camera0.CoordinateFrame = CFrame.new(0.321689844, 18.2346153, 23.7645969, 0.98357147, -0.0819535926, 0.160844535, -0, 0.891008377, 0.453987002, -0.180519685, -0.446528673, 0.876370251)
  68. Camera0.Focus = CFrame.new(0, 17.3266392, 22.0118523, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  69. Camera0.focus = CFrame.new(0, 17.3266392, 22.0118523, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  70. Part1.Name = "Baseplate"
  71. Part1.Parent = mas
  72. Part1.CFrame = CFrame.new(0, -10, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  73. Part1.Position = Vector3.new(0, -10, 0)
  74. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  75. Part1.Size = Vector3.new(512, 20, 512)
  76. Part1.Anchored = true
  77. Part1.BrickColor = BrickColor.new("Dark stone grey")
  78. Part1.Locked = true
  79. Part1.brickColor = BrickColor.new("Dark stone grey")
  80. Part1.FormFactor = Enum.FormFactor.Symmetric
  81. Part1.formFactor = Enum.FormFactor.Symmetric
  82. Tool2.Name = "Handgun"
  83. Tool2.Parent = mas
  84. Tool2.TextureId = "http://www.roblox.com/asset/?id=122080118"
  85. Tool2.CanBeDropped = false
  86. Tool2.Grip = CFrame.new(0, -0.349999994, -0.100000016, -0.998458922, 0.0554731078, 0.00161359028, 0.0554737262, 0.998460174, 0.000344417145, -0.0015919999, 0.000433398294, -0.999998569)
  87. Tool2.GripForward = Vector3.new(-0.00161359028, -0.000344417145, 0.999998569)
  88. Tool2.GripPos = Vector3.new(0, -0.349999994, -0.100000016)
  89. Tool2.GripRight = Vector3.new(-0.998458922, 0.0554737262, -0.0015919999)
  90. Tool2.GripUp = Vector3.new(0.0554731078, 0.998460174, 0.000433398294)
  91. Tool2.ToolTip = "Handgun"
  92. UnionOperation3.Name = "Handle"
  93. UnionOperation3.Parent = Tool2
  94. UnionOperation3.CFrame = CFrame.new(-4.87051725, 0.607330322, -38.0968056, -1.00000072, 1.05220526e-08, -5.9604659e-08, -1.05220526e-08, 1.00000024, 8.11945622e-09, -5.9604659e-08, -8.11945622e-09, -1.00000072)
  95. UnionOperation3.Orientation = Vector3.new(0, -180, 0)
  96. UnionOperation3.Position = Vector3.new(-4.87051725, 0.607330322, -38.0968056)
  97. UnionOperation3.Rotation = Vector3.new(-180, 0, -180)
  98. UnionOperation3.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  99. UnionOperation3.Size = Vector3.new(0.218962356, 1.11467886, 1.54634953)
  100. UnionOperation3.BrickColor = BrickColor.new("Really black")
  101. UnionOperation3.Material = Enum.Material.SmoothPlastic
  102. UnionOperation3.Reflectance = 0.10000000149012
  103. UnionOperation3.brickColor = BrickColor.new("Really black")
  104. Sound4.Name = "EquipSound"
  105. Sound4.Parent = UnionOperation3
  106. Sound4.SoundId = "http://www.roblox.com/asset/?id=171140306"
  107. Sound4.Volume = 0.20000000298023
  108. Sound5.Name = "FireSound"
  109. Sound5.Parent = UnionOperation3
  110. Sound5.SoundId = "rbxassetid://143286342"
  111. Sound5.Volume = 1
  112. Sound6.Name = "Reload"
  113. Sound6.Parent = UnionOperation3
  114. Sound6.Pitch = 0.89999997615814
  115. Sound6.PlaybackSpeed = 0.89999997615814
  116. Sound6.SoundId = "http://www.roblox.com/asset/?id=174295321"
  117. Sound6.Volume = 1
  118. Sound7.Name = "Tick"
  119. Sound7.Parent = UnionOperation3
  120. Sound7.SoundId = "rbxassetid://154255000"
  121. Sound7.Volume = 1
  122. PointLight8.Name = "Flash"
  123. PointLight8.Parent = UnionOperation3
  124. PointLight8.Color = Color3.new(1, 0.568627, 0.192157)
  125. PointLight8.Enabled = false
  126. PointLight8.Shadows = true
  127. Smoke9.Parent = UnionOperation3
  128. Smoke9.Color = Color3.new(0.392157, 0.392157, 0.392157)
  129. Smoke9.Enabled = false
  130. Smoke9.Size = 0.10000000149012
  131. Smoke9.Opacity = 0.10000000149012
  132. Smoke9.RiseVelocity = 4
  133. Sound10.Name = "EquipSound2"
  134. Sound10.Parent = UnionOperation3
  135. Sound10.SoundId = "http://www.roblox.com/asset/?id=169310310"
  136. Sound10.Volume = 0.60000002384186
  137. Sound11.Name = "UnequipSound"
  138. Sound11.Parent = UnionOperation3
  139. Sound11.Pitch = 1.5
  140. Sound11.PlaybackSpeed = 1.5
  141. Sound11.SoundId = "http://www.roblox.com/asset/?id=169310310"
  142. Sound11.Volume = 0.30000001192093
  143. Animation12.Name = "Recoil"
  144. Animation12.Parent = Tool2
  145. Animation12.AnimationId = "http://www.roblox.com/Asset?ID=177443776"
  146. LocalScript13.Name = "HandgunScript"
  147. LocalScript13.Parent = Tool2
  148. table.insert(cors,sandbox(LocalScript13,function()
  149. --------------------- TEMPLATE WEAPON ---------------------------
  150. --edited by DestinyHarbinger
  151. -- Waits for the child of the specified parent
  152. local function WaitForChild(parent, childName)
  153. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  154. return parent[childName]
  155. end
  156.  
  157. ----- TOOL DATA -----
  158. -- How much damage a bullet does
  159. local Damage = 18
  160. -- How many times per second the gun can fire
  161. local FireRate = 1 / 5.5
  162. -- The maximum distance the can can shoot, this value should never go above 1000
  163. local Range = 999
  164. -- In radians the minimum accuracy penalty
  165. local MinSpread = 0.005
  166. -- In radian the maximum accuracy penalty
  167. local MaxSpread = 0.07
  168. -- Number of bullets in a clip
  169. local ClipSize = 7
  170. -- DefaultValue for spare ammo
  171. local SpareAmmo = 999
  172. -- The amount the aim will increase or decrease by
  173. -- decreases this number reduces the speed that recoil takes effect
  174. local AimInaccuracyStepAmount = .5
  175. -- Time it takes to reload weapon
  176. local ReloadTime = 2.1
  177. ----------------------------------------
  178.  
  179. -- Colors
  180. local FriendlyReticleColor = Color3.new(0, 1, 0)
  181. local EnemyReticleColor = Color3.new(1, 0, 0)
  182. local NeutralReticleColor = Color3.new(1, 1, 1)
  183.  
  184. local Spread = MinSpread
  185. local AmmoInClip = ClipSize
  186.  
  187. local Tool = script.Parent
  188. local Handle = WaitForChild(Tool, 'Handle')
  189. local WeaponGui = nil
  190.  
  191. local LeftButtonDown
  192. local Reloading = false
  193. local IsShooting = false
  194. local Pitch = script.Parent.Handle.FireSound
  195.  
  196. -- Player specific convenience variables
  197. local MyPlayer = nil
  198. local MyCharacter = nil
  199. local MyHumanoid = nil
  200. local MyTorso = nil
  201. local MyMouse = nil
  202.  
  203.  
  204. local RecoilAnim
  205. local RecoilTrack = nil
  206.  
  207. local ReloadAnim
  208. local ReloadTrack = nil
  209.  
  210. local IconURL = Tool.TextureId
  211. local DebrisService = game:GetService('Debris')
  212. local PlayersService = game:GetService('Players')
  213.  
  214.  
  215. local FireSound
  216.  
  217. local OnFireConnection = nil
  218. local OnReloadConnection = nil
  219.  
  220. local DecreasedAimLastShot = false
  221. local LastSpreadUpdate = time()
  222.  
  223. local flare = script.Parent:WaitForChild("Flare")
  224.  
  225. -- this is a dummy object that holds the flash made when the gun is fired
  226. local FlashHolder = nil
  227.  
  228.  
  229. local WorldToCellFunction = Workspace.Terrain.WorldToCellPreferSolid
  230. local GetCellFunction = Workspace.Terrain.GetCell
  231.  
  232. function RayIgnoreCheck(hit, pos)
  233. if hit then
  234. if hit.Transparency >= 1 or string.lower(hit.Name) == "water" or
  235. hit.Name == "Effect" or hit.Name == "Rocket" or hit.Name == "Bullet" or
  236. hit.Name == "Handle" or hit:IsDescendantOf(MyCharacter) then
  237. return true
  238. elseif hit:IsA('Terrain') and pos then
  239. local cellPos = WorldToCellFunction(Workspace.Terrain, pos)
  240. if cellPos then
  241. local cellMat = GetCellFunction(Workspace.Terrain, cellPos.x, cellPos.y, cellPos.z)
  242. if cellMat and cellMat == Enum.CellMaterial.Water then
  243. return true
  244. end
  245. end
  246. end
  247. end
  248. return false
  249. end
  250.  
  251. -- @preconditions: vec should be a unit vector, and 0 < rayLength <= 1000
  252. function RayCast(startPos, vec, rayLength)
  253. local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle)
  254. if hitObject and hitPos then
  255. local distance = rayLength - (hitPos - startPos).magnitude
  256. if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
  257. -- there is a chance here for potential infinite recursion
  258. return RayCast(hitPos, vec, distance)
  259. end
  260. end
  261. return hitObject, hitPos
  262. end
  263.  
  264.  
  265.  
  266. function TagHumanoid(humanoid, player)
  267. -- Add more tags here to customize what tags are available.
  268. while humanoid:FindFirstChild('creator') do
  269. humanoid:FindFirstChild('creator'):Destroy()
  270. end
  271. local creatorTag = Instance.new("ObjectValue")
  272. creatorTag.Value = player
  273. creatorTag.Name = "creator"
  274. creatorTag.Parent = humanoid
  275. DebrisService:AddItem(creatorTag, 1.5)
  276.  
  277. local weaponIconTag = Instance.new("StringValue")
  278. weaponIconTag.Value = IconURL
  279. weaponIconTag.Name = "icon"
  280. weaponIconTag.Parent = creatorTag
  281. end
  282.  
  283.  
  284. local function CreateBullet(bulletPos)
  285. local bullet = Instance.new('Part', Workspace)
  286. bullet.FormFactor = Enum.FormFactor.Custom
  287. bullet.Size = Vector3.new(0.1, 0.1, 0.1)
  288. bullet.BrickColor = BrickColor.new("Black")
  289. bullet.Shape = Enum.PartType.Block
  290. bullet.CanCollide = false
  291. bullet.CFrame = CFrame.new(bulletPos)
  292. bullet.Anchored = true
  293. bullet.TopSurface = Enum.SurfaceType.Smooth
  294. bullet.BottomSurface = Enum.SurfaceType.Smooth
  295. bullet.Name = 'Bullet'
  296. DebrisService:AddItem(bullet, 2.5)
  297.  
  298. local shell = Instance.new("Part")
  299. shell.CFrame = Tool.Handle.CFrame * CFrame.fromEulerAnglesXYZ(1.5,0,0)
  300. shell.Size = Vector3.new(1,1,1)
  301. shell.BrickColor = BrickColor.new(226)
  302. shell.Parent = game.Workspace
  303. shell.CFrame = script.Parent.Handle.CFrame
  304. shell.CanCollide = false
  305. shell.Transparency = 0
  306. shell.BottomSurface = 0
  307. shell.TopSurface = 0
  308. shell.Name = "Shell"
  309. shell.Velocity = Tool.Handle.CFrame.lookVector * 35 + Vector3.new(math.random(-10,10),20,math.random(-10,20))
  310. shell.RotVelocity = Vector3.new(0,200,0)
  311. DebrisService:AddItem(shell, 1)
  312.  
  313. local shellmesh = Instance.new("SpecialMesh")
  314. shellmesh.Scale = Vector3.new(.15,.4,.15)
  315. shellmesh.Parent = shell
  316.  
  317. return bullet
  318. end
  319.  
  320. local function Reload()
  321. if not Reloading then
  322. Reloading = true
  323. -- Don't reload if you are already full or have no extra ammo
  324. if AmmoInClip ~= ClipSize and SpareAmmo > 0 then
  325. if RecoilTrack then
  326. RecoilTrack:Stop()
  327. end
  328. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
  329. if WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
  330. WeaponGui.Crosshair.ReloadingLabel.Visible = true
  331. end
  332. end
  333. if ReloadTrack then
  334. ReloadTrack:Play()
  335. end
  336. script.Parent.Handle.Reload:Play()
  337. wait(ReloadTime)
  338. -- Only use as much ammo as you have
  339. local ammoToUse = math.min(ClipSize - AmmoInClip, SpareAmmo)
  340. AmmoInClip = AmmoInClip + ammoToUse
  341. SpareAmmo = SpareAmmo - ammoToUse
  342. UpdateAmmo(AmmoInClip)
  343. --WeaponGui.Reload.Visible = false
  344. if ReloadTrack then
  345. ReloadTrack:Stop()
  346. end
  347. end
  348. Reloading = false
  349. end
  350. end
  351.  
  352. function OnFire()
  353. if IsShooting then return end
  354. if MyHumanoid and MyHumanoid.Health > 0 then
  355. if RecoilTrack and AmmoInClip > 0 then
  356. RecoilTrack:Play()
  357. end
  358. IsShooting = true
  359. while LeftButtonDown and AmmoInClip > 0 and not Reloading do
  360. if Spread and not DecreasedAimLastShot then
  361. Spread = math.min(MaxSpread, Spread + AimInaccuracyStepAmount)
  362. UpdateCrosshair(Spread)
  363. end
  364. DecreasedAimLastShot = not DecreasedAimLastShot
  365. if Handle:FindFirstChild('FireSound') then
  366. Pitch.Pitch = .8 + (math.random() * .5)
  367. Handle.FireSound:Play()
  368. Handle.Flash.Enabled = true
  369. flare.MuzzleFlash.Enabled = true
  370. --Handle.Smoke.Enabled=true --This is optional
  371. end
  372. if MyMouse then
  373. local targetPoint = MyMouse.Hit.p
  374. local shootDirection = (targetPoint - Handle.Position).unit
  375. -- Adjust the shoot direction randomly off by a little bit to account for recoil
  376. shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
  377. (0.5 - math.random()) * 2 * Spread,
  378. (0.5 - math.random()) * 2 * Spread) * shootDirection
  379. local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
  380. local bullet
  381. -- Create a bullet here
  382. if hitObject then
  383. bullet = CreateBullet(bulletPos)
  384. end
  385. if hitObject and hitObject.Parent then
  386. local hitHumanoid = hitObject.Parent:FindFirstChild("Humanoid")
  387. if hitHumanoid then
  388. local hitPlayer = game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)
  389. if MyPlayer.Neutral or (hitPlayer and hitPlayer.TeamColor ~= MyPlayer.TeamColor) then
  390. TagHumanoid(hitHumanoid, MyPlayer)
  391. hitHumanoid:TakeDamage(Damage)
  392. if bullet then
  393. bullet:Destroy()
  394. bullet = nil
  395. WeaponGui.Crosshair.Hit:Play()
  396. --bullet.Transparency = 1
  397. end
  398. Spawn(UpdateTargetHit)
  399. end
  400. end
  401. end
  402. AmmoInClip = AmmoInClip - 1
  403. UpdateAmmo(AmmoInClip)
  404. end
  405. wait(FireRate)
  406. end
  407. Handle.Flash.Enabled = false
  408. IsShooting = false
  409. flare.MuzzleFlash.Enabled = false
  410. --Handle.Smoke.Enabled=false --This is optional
  411. if AmmoInClip == 0 then
  412. Handle.Tick:Play()
  413. --WeaponGui.Reload.Visible = true
  414. Reload()
  415. end
  416. if RecoilTrack then
  417. RecoilTrack:Stop()
  418. end
  419. end
  420. end
  421.  
  422. local TargetHits = 0
  423. function UpdateTargetHit()
  424. TargetHits = TargetHits + 1
  425. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
  426. WeaponGui.Crosshair.TargetHitImage.Visible = true
  427. end
  428. wait(0.5)
  429. TargetHits = TargetHits - 1
  430. if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
  431. WeaponGui.Crosshair.TargetHitImage.Visible = false
  432. end
  433. end
  434.  
  435. function UpdateCrosshair(value, mouse)
  436. if WeaponGui then
  437. local absoluteY = 650
  438. WeaponGui.Crosshair:TweenSize(
  439. UDim2.new(0, value * absoluteY * 2 + 23, 0, value * absoluteY * 2 + 23),
  440. Enum.EasingDirection.Out,
  441. Enum.EasingStyle.Linear,
  442. 0.33)
  443. end
  444. end
  445.  
  446. function UpdateAmmo(value)
  447. if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
  448. WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
  449. if value > 0 and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
  450. WeaponGui.Crosshair.ReloadingLabel.Visible = false
  451. end
  452. end
  453. if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
  454. WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
  455. end
  456. end
  457.  
  458.  
  459. function OnMouseDown()
  460. LeftButtonDown = true
  461. OnFire()
  462. end
  463.  
  464. function OnMouseUp()
  465. LeftButtonDown = false
  466. end
  467.  
  468. function OnKeyDown(key)
  469. if string.lower(key) == 'r' then
  470. Reload()
  471. if RecoilTrack then
  472. RecoilTrack:Stop()
  473. end
  474. end
  475. end
  476.  
  477.  
  478. function OnEquipped(mouse)
  479. Handle.EquipSound:Play()
  480. Handle.EquipSound2:Play()
  481. Handle.UnequipSound:Stop()
  482. RecoilAnim = WaitForChild(Tool, 'Recoil')
  483. ReloadAnim = WaitForChild(Tool, 'Reload')
  484. FireSound = WaitForChild(Handle, 'FireSound')
  485.  
  486. MyCharacter = Tool.Parent
  487. MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
  488. MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
  489. MyTorso = MyCharacter:FindFirstChild('Torso')
  490. MyMouse = mouse
  491. WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()
  492. if WeaponGui and MyPlayer then
  493. WeaponGui.Parent = MyPlayer.PlayerGui
  494. UpdateAmmo(AmmoInClip)
  495. end
  496. if RecoilAnim then
  497. RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
  498. end
  499.  
  500. if ReloadAnim then
  501. ReloadTrack = MyHumanoid:LoadAnimation(ReloadAnim)
  502. end
  503.  
  504. if MyMouse then
  505. -- Disable mouse icon
  506. MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
  507. MyMouse.Button1Down:connect(OnMouseDown)
  508. MyMouse.Button1Up:connect(OnMouseUp)
  509. MyMouse.KeyDown:connect(OnKeyDown)
  510. end
  511. end
  512.  
  513.  
  514. -- Unequip logic here
  515. function OnUnequipped()
  516. Handle.UnequipSound:Play()
  517. Handle.EquipSound:Stop()
  518. Handle.EquipSound2:Stop()
  519. LeftButtonDown = false
  520. flare.MuzzleFlash.Enabled = false
  521. Reloading = false
  522. MyCharacter = nil
  523. MyHumanoid = nil
  524. MyTorso = nil
  525. MyPlayer = nil
  526. MyMouse = nil
  527. if OnFireConnection then
  528. OnFireConnection:disconnect()
  529. end
  530. if OnReloadConnection then
  531. OnReloadConnection:disconnect()
  532. end
  533. if FlashHolder then
  534. FlashHolder = nil
  535. end
  536. if WeaponGui then
  537. WeaponGui.Parent = nil
  538. WeaponGui = nil
  539. end
  540. if RecoilTrack then
  541. RecoilTrack:Stop()
  542. end
  543. if ReloadTrack then
  544. ReloadTrack:Stop()
  545. end
  546. end
  547.  
  548. local function SetReticleColor(color)
  549. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
  550. for _, line in pairs(WeaponGui.Crosshair:GetChildren()) do
  551. if line:IsA('Frame') then
  552. line.BorderColor3 = color
  553. end
  554. end
  555. end
  556. end
  557.  
  558.  
  559. Tool.Equipped:connect(OnEquipped)
  560. Tool.Unequipped:connect(OnUnequipped)
  561.  
  562. while true do
  563. wait(0.033)
  564. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and MyMouse then
  565. WeaponGui.Crosshair.Position = UDim2.new(0, MyMouse.X, 0, MyMouse.Y)
  566. SetReticleColor(NeutralReticleColor)
  567.  
  568. local target = MyMouse.Target
  569. if target and target.Parent then
  570. local player = PlayersService:GetPlayerFromCharacter(target.Parent)
  571. if player then
  572. if MyPlayer.Neutral or player.TeamColor ~= MyPlayer.TeamColor then
  573. SetReticleColor(EnemyReticleColor)
  574. else
  575. SetReticleColor(FriendlyReticleColor)
  576. end
  577. end
  578. end
  579. end
  580. if Spread and not IsShooting then
  581. local currTime = time()
  582. if currTime - LastSpreadUpdate > FireRate * 2 then
  583. LastSpreadUpdate = currTime
  584. Spread = math.max(MinSpread, Spread - AimInaccuracyStepAmount)
  585. UpdateCrosshair(Spread, MyMouse)
  586. end
  587. end
  588. end
  589.  
  590. end))
  591. Script14.Name = "WeldingDoNotDelete"
  592. Script14.Parent = Tool2
  593. table.insert(cors,sandbox(Script14,function()
  594. --DO NOT DELETE, THIS WILL BREAK THE GUN
  595.  
  596. function Stick(x, y)
  597. local W = Instance.new("Weld")
  598. W.Part0 = x
  599. W.Part1 = y
  600. local CJ = CFrame.new(x.Position)
  601. local C0 = x.CFrame:inverse()*CJ
  602. local C1 = y.CFrame:inverse()*CJ
  603. W.C0 = C0
  604. W.C1 = C1
  605. W.Parent = x
  606. end
  607.  
  608. function Get(A)
  609. if A.ClassName == ("Part") then
  610. Stick(script.Parent.Handle, A)
  611. A.Anchored = false
  612. else
  613. local C = A:GetChildren()
  614. for i=1, #C do
  615. Get(C[i])
  616. end
  617. end
  618. end
  619.  
  620. function Finale()
  621. Get(script.Parent)
  622. end
  623.  
  624. script.Parent.Equipped:connect(Finale)
  625. script.Parent.Unequipped:connect(Finale)
  626. Finale()
  627. end))
  628. Part15.Name = "Flare"
  629. Part15.Parent = Tool2
  630. Part15.CFrame = CFrame.new(-4.87999678, 0.979990602, -39.1899796, 1.00000036, -2.40926101e-09, -1.1920929e-07, 1.29313085e-08, 1.00000012, -8.11945711e-09, 1.78813934e-07, 1.11022302e-15, 1.00000036)
  631. Part15.Position = Vector3.new(-4.87999678, 0.979990602, -39.1899796)
  632. Part15.Transparency = 1
  633. Part15.Size = Vector3.new(1, 1, 1)
  634. Part15.CanCollide = false
  635. Part15.FormFactor = Enum.FormFactor.Symmetric
  636. Part15.formFactor = Enum.FormFactor.Symmetric
  637. BillboardGui16.Name = "MuzzleFlash"
  638. BillboardGui16.Parent = Part15
  639. BillboardGui16.Enabled = false
  640. BillboardGui16.Size = UDim2.new(2, 0, 2, 0)
  641. ImageLabel17.Name = "Img"
  642. ImageLabel17.Parent = BillboardGui16
  643. ImageLabel17.Size = UDim2.new(1, 0, 1, 0)
  644. ImageLabel17.BackgroundTransparency = 1
  645. ImageLabel17.Image = "http://www.roblox.com/asset/?ID=103740493"
  646. Script18.Parent = ImageLabel17
  647. table.insert(cors,sandbox(Script18,function()
  648. local imgs = {103740493,103804266,103804383}
  649. for _,v in pairs(imgs) do
  650. game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?ID="..v)
  651. end
  652.  
  653. script.Parent.Parent.Changed:connect(function ()
  654. if script.Parent.Parent.Enabled == true then
  655. wait(0.09)
  656. script.Parent.Parent.Enabled = false
  657. end
  658. end)
  659.  
  660. while true do
  661. for i = 1,#imgs do
  662. script.Parent.Image = "http://www.roblox.com/asset/?ID="..imgs[i]
  663. wait(0.03)
  664. end
  665. end
  666.  
  667. end))
  668. Animation19.Name = "Reload"
  669. Animation19.Parent = Tool2
  670. Animation19.AnimationId = "http://www.roblox.com/Asset?ID=95384819"
  671. Script20.Name = "Readme From Destiny"
  672. Script20.Parent = Tool2
  673. table.insert(cors,sandbox(Script20,function()
  674. --[[HANDGUN v1.2 CREATED BY DESTINYHARBINGER
  675.  
  676. A fully working, non virus riddled, and decently realistic up to date handgun made from a Unioned Part
  677. made from solid modeling. This weapon is actually an edited Template Assualt Rifle you can see from those
  678. broken template games. Modified to become more modern and up to date.
  679.  
  680. This weapon features:
  681. -Anti Teamkill
  682. -Flashes and Flares and Bears Oh My!
  683. -Reloading (WOWWWWWWW)
  684. -IOS and Android Compatibility (Tested and Approved)
  685. -No virus junk.
  686. -Animations (will improve later)
  687. -Easy to edit script!
  688. -Decent pistol sounds!
  689. -Non-laggy! Only 2 parts and thats it!
  690. -and not so much more because its just a regular gun!!!!!!!
  691.  
  692. )))))))))IMPORTANT:
  693. DO NOT DELETE, UNUNION, OR CHANGE NAMES OF ANYTHING UNLESS YOU ARE AN EXPERT AT DOING THAT BUISNESS.
  694. TREAD CAREFULLY.
  695.  
  696.  
  697. ~PATCH NOTES~
  698. v1.2
  699. -Tool not working if in starterpack has been fixed by Luckymaxer.
  700. -Minor HUD changes.
  701.  
  702.  
  703. v1.1
  704. -Smoke is now disabled. Go through the handgun script and CTRL + F, search smoke, and uncomment the options
  705. for it to work again.
  706. -Shell casings have been added
  707. -When sucessfully hitting someone, a local sound is played to indicate a hit.
  708. -Works with mobile now. Thats right, you can now use it on iPhone Sean.
  709. -Changed Equipping sounds.
  710.  
  711. ______ _____ _____ _____ _____ _ _ __ __
  712. | _ \| ___|/ ___||_ _||_ _|| \ | |\ \ / /
  713. | | | || |__ \ `--. | | | | | \| | \ V /
  714. | | | || __| `--. \ | | | | | . ` | \ /
  715. | |/ / | |___ /\__/ / | | _| |_ | |\ | | |
  716. |___/ \____/ \____/ \_/ \___/ \_| \_/ \_/
  717.  
  718.  
  719. _ _ ___ ______ ______ _____ _ _ _____ _____ ______
  720. | | | | / _ \ | ___ \| ___ \|_ _|| \ | || __ \| ___|| ___ \
  721. | |_| |/ /_\ \| |_/ /| |_/ / | | | \| || | \/| |__ | |_/ /
  722. | _ || _ || / | ___ \ | | | . ` || | __ | __| | /
  723. | | | || | | || |\ \ | |_/ / _| |_ | |\ || |_\ \| |___ | |\ \
  724. \_| |_/\_| |_/\_| \_|\____/ \___/ \_| \_/ \____/\____/ \_| \_|
  725. __ __ _____ _____ _____ ______ _____ _____ __ _____
  726. / / \ \ / __ \| _ || _ ||___ / / __ \| _ |/ | | ___|
  727. | | ___ | | `' / /'| |/' || |/' | / /______`' / /'| |/' |`| | |___ \
  728. | | / __|| | / / | /| || /| | / /|______| / / | /| | | | \ \
  729. | || (__ | | ./ /___\ |_/ /\ |_/ /./ / ./ /___\ |_/ /_| |_/\__/ /
  730. | | \___|| | \_____/ \___/ \___/ \_/ \_____/ \___/ \___/\____/
  731. \_\ /_/
  732.  
  733. If you can, leave me some credit k ;)
  734.  
  735. ]]
  736. end))
  737. Camera21.Name = "ThumbnailCamera"
  738. Camera21.Parent = Tool2
  739. Camera21.CFrame = CFrame.new(-7.073627, 1.91333532, -40.2050323, -0.684124351, 0.268417299, -0.678178549, 1.49011612e-08, 0.929820061, 0.368014812, 0.729365468, 0.251767904, -0.636112452)
  740. Camera21.CoordinateFrame = CFrame.new(-7.073627, 1.91333532, -40.2050323, -0.684124351, 0.268417299, -0.678178549, 1.49011612e-08, 0.929820061, 0.368014812, 0.729365468, 0.251767904, -0.636112452)
  741. Camera21.FieldOfView = 25.000000418326
  742. Camera21.Focus = CFrame.new(-5.71727037, 1.17730594, -38.9328079, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  743. Camera21.focus = CFrame.new(-5.71727037, 1.17730594, -38.9328079, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  744. ScreenGui22.Name = "WeaponHud"
  745. ScreenGui22.Parent = Tool2
  746. Frame23.Name = "AmmoHud"
  747. Frame23.Parent = ScreenGui22
  748. Frame23.Position = UDim2.new(1, -265, 1, -60)
  749. Frame23.Size = UDim2.new(0, 200, 0, 50)
  750. Frame23.BackgroundTransparency = 1
  751. Frame23.BorderSizePixel = 0
  752. TextLabel24.Name = "ForwardSlash"
  753. TextLabel24.Parent = Frame23
  754. TextLabel24.Position = UDim2.new(0.5, 0, 0.5, 0)
  755. TextLabel24.BackgroundTransparency = 1
  756. TextLabel24.BorderSizePixel = 0
  757. TextLabel24.Font = Enum.Font.SourceSans
  758. TextLabel24.FontSize = Enum.FontSize.Size24
  759. TextLabel24.Text = "/"
  760. TextLabel24.TextColor = BrickColor.new("Institutional white")
  761. TextLabel24.TextColor3 = Color3.new(1, 1, 1)
  762. TextLabel24.TextScaled = true
  763. TextLabel24.TextSize = 24
  764. TextLabel24.TextStrokeTransparency = 0
  765. TextLabel24.TextWrap = true
  766. TextLabel24.TextWrapped = true
  767. TextLabel25.Name = "ClipAmmo"
  768. TextLabel25.Parent = Frame23
  769. TextLabel25.Position = UDim2.new(0.449999988, 0, 0.5, 0)
  770. TextLabel25.BackgroundTransparency = 1
  771. TextLabel25.BorderSizePixel = 0
  772. TextLabel25.Font = Enum.Font.SourceSansBold
  773. TextLabel25.FontSize = Enum.FontSize.Size24
  774. TextLabel25.Text = "54"
  775. TextLabel25.TextColor = BrickColor.new("Institutional white")
  776. TextLabel25.TextColor3 = Color3.new(1, 1, 1)
  777. TextLabel25.TextScaled = true
  778. TextLabel25.TextSize = 24
  779. TextLabel25.TextStrokeTransparency = 0
  780. TextLabel25.TextWrap = true
  781. TextLabel25.TextWrapped = true
  782. TextLabel25.TextXAlignment = Enum.TextXAlignment.Right
  783. TextLabel26.Name = "TotalAmmo"
  784. TextLabel26.Parent = Frame23
  785. TextLabel26.Position = UDim2.new(0.550000012, 0, 0.5, 0)
  786. TextLabel26.BackgroundTransparency = 1
  787. TextLabel26.BorderSizePixel = 0
  788. TextLabel26.Font = Enum.Font.SourceSans
  789. TextLabel26.FontSize = Enum.FontSize.Size24
  790. TextLabel26.Text = "180"
  791. TextLabel26.TextColor = BrickColor.new("Institutional white")
  792. TextLabel26.TextColor3 = Color3.new(1, 1, 1)
  793. TextLabel26.TextScaled = true
  794. TextLabel26.TextSize = 24
  795. TextLabel26.TextStrokeTransparency = 0
  796. TextLabel26.TextWrap = true
  797. TextLabel26.TextWrapped = true
  798. TextLabel26.TextXAlignment = Enum.TextXAlignment.Left
  799. ImageLabel27.Parent = Frame23
  800. ImageLabel27.Size = UDim2.new(0, 200, 0, 50)
  801. ImageLabel27.BackgroundColor = BrickColor.new("Institutional white")
  802. ImageLabel27.BackgroundColor3 = Color3.new(1, 1, 1)
  803. ImageLabel27.BackgroundTransparency = 1
  804. ImageLabel27.BorderColor = BrickColor.new("Really black")
  805. ImageLabel27.BorderColor3 = Color3.new(0, 0, 0)
  806. ImageLabel27.BorderSizePixel = 0
  807. ImageLabel27.Image = "rbxassetid://51219827"
  808. ImageLabel27.ImageColor3 = Color3.new(0.352941, 0.352941, 0.352941)
  809. ImageLabel27.ImageTransparency = 0.20000000298023
  810. Frame28.Name = "Crosshair"
  811. Frame28.Parent = ScreenGui22
  812. Frame28.Position = UDim2.new(0, 500, 0, 500)
  813. Frame28.Size = UDim2.new(0, 150, 0, 150)
  814. Frame28.BackgroundColor = BrickColor.new("Lime green")
  815. Frame28.BackgroundColor3 = Color3.new(0, 1, 0)
  816. Frame28.BackgroundTransparency = 1
  817. Frame28.BorderSizePixel = 0
  818. Frame29.Name = "TopFrame"
  819. Frame29.Parent = Frame28
  820. Frame29.Position = UDim2.new(0, -1, -0.5, -7)
  821. Frame29.Size = UDim2.new(0, 2, 0, 14)
  822. Frame29.BackgroundColor = BrickColor.new("Really black")
  823. Frame29.BackgroundColor3 = Color3.new(0, 0, 0)
  824. Frame29.BorderColor = BrickColor.new("Institutional white")
  825. Frame29.BorderColor3 = Color3.new(1, 1, 1)
  826. Frame30.Name = "RightFrame"
  827. Frame30.Parent = Frame28
  828. Frame30.Position = UDim2.new(0.5, -7, 0, -1)
  829. Frame30.Size = UDim2.new(0, 14, 0, 2)
  830. Frame30.BackgroundColor = BrickColor.new("Really black")
  831. Frame30.BackgroundColor3 = Color3.new(0, 0, 0)
  832. Frame30.BorderColor = BrickColor.new("Institutional white")
  833. Frame30.BorderColor3 = Color3.new(1, 1, 1)
  834. Frame31.Name = "LeftFrame"
  835. Frame31.Parent = Frame28
  836. Frame31.Position = UDim2.new(-0.5, -7, 0, -1)
  837. Frame31.Size = UDim2.new(0, 14, 0, 2)
  838. Frame31.BackgroundColor = BrickColor.new("Really black")
  839. Frame31.BackgroundColor3 = Color3.new(0, 0, 0)
  840. Frame31.BorderColor = BrickColor.new("Institutional white")
  841. Frame31.BorderColor3 = Color3.new(1, 1, 1)
  842. ImageLabel32.Name = "TargetHitImage"
  843. ImageLabel32.Parent = Frame28
  844. ImageLabel32.Position = UDim2.new(0, -25, 0, -25)
  845. ImageLabel32.Visible = false
  846. ImageLabel32.Size = UDim2.new(0, 50, 0, 50)
  847. ImageLabel32.BackgroundTransparency = 1
  848. ImageLabel32.BorderSizePixel = 0
  849. ImageLabel32.Image = "http://www.roblox.com/asset/?id=115400215"
  850. TextLabel33.Name = "ReloadingLabel"
  851. TextLabel33.Parent = Frame28
  852. TextLabel33.Position = UDim2.new(0, 20, 0, -20)
  853. TextLabel33.Visible = false
  854. TextLabel33.BackgroundTransparency = 1
  855. TextLabel33.BorderSizePixel = 0
  856. TextLabel33.Font = Enum.Font.ArialBold
  857. TextLabel33.FontSize = Enum.FontSize.Size18
  858. TextLabel33.Text = "Reloading"
  859. TextLabel33.TextColor = BrickColor.new("Crimson")
  860. TextLabel33.TextColor3 = Color3.new(0.568627, 0, 0)
  861. TextLabel33.TextSize = 18
  862. TextLabel33.TextStrokeTransparency = 0
  863. TextLabel33.TextXAlignment = Enum.TextXAlignment.Left
  864. TextLabel33.TextYAlignment = Enum.TextYAlignment.Bottom
  865. Frame34.Name = "BottomFrame"
  866. Frame34.Parent = Frame28
  867. Frame34.Position = UDim2.new(0, -1, 0.5, -7)
  868. Frame34.Size = UDim2.new(0, 2, 0, 14)
  869. Frame34.BackgroundColor = BrickColor.new("Really black")
  870. Frame34.BackgroundColor3 = Color3.new(0, 0, 0)
  871. Frame34.BorderColor = BrickColor.new("Institutional white")
  872. Frame34.BorderColor3 = Color3.new(1, 1, 1)
  873. Sound35.Name = "Hit"
  874. Sound35.Parent = Frame28
  875. Sound35.SoundId = "rbxassetid://160432334"
  876. Sound35.Volume = 1
  877. Script36.Parent = Tool2
  878. table.insert(cors,sandbox(Script36,function()
  879. gear.Parent = Player.Character
  880. end))
  881. Script37.Parent = mas
  882. for i,v in pairs(mas:GetChildren()) do
  883. v.Parent = workspace
  884. pcall(function() v:MakeJoints() end)
  885. end
  886. mas:Destroy()
  887. for i,v in pairs(cors) do
  888. spawn(function()
  889. pcall(v)
  890. end)
  891. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement