Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.77 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
  6. print("FE Compatibility code V2 by Mokiros")
  7. local RealPlayer = RealPlayer
  8. script.Parent = RealPlayer.Character
  9.  
  10. --Fake event to make stuff like Mouse.KeyDown work
  11. local Disconnect_Function = function(this)
  12. this[1].Functions[this[2]] = nil
  13. end
  14. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  15. local FakeEvent_Metatable = {__index={
  16. Connect = function(this,f)
  17. local i = tostring(math.random(0,10000))
  18. while this.Functions[i] do
  19. i = tostring(math.random(0,10000))
  20. end
  21. this.Functions[i] = f
  22. return setmetatable({this,i},Disconnect_Metatable)
  23. end
  24. }}
  25. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  26. local function fakeEvent()
  27. return setmetatable({Functions={}},FakeEvent_Metatable)
  28. end
  29.  
  30. --Creating fake input objects with fake variables
  31. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  32. FakeMouse.keyUp = FakeMouse.KeyUp
  33. FakeMouse.keyDown = FakeMouse.KeyDown
  34. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  35. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  36. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  37. end}
  38. --Merged 2 functions into one by checking amount of arguments
  39. CAS.UnbindAction = CAS.BindAction
  40.  
  41. --This function will trigger the events that have been :Connect()'ed
  42. local function TriggerEvent(self,ev,...)
  43. for _,f in pairs(self[ev].Functions) do
  44. f(...)
  45. end
  46. end
  47. FakeMouse.TriggerEvent = TriggerEvent
  48. UIS.TriggerEvent = TriggerEvent
  49.  
  50. --Client communication
  51. local Event = Instance.new("RemoteEvent")
  52. Event.Name = "UserInput_Event"
  53. Event.OnServerEvent:Connect(function(plr,io)
  54. if plr~=RealPlayer then return end
  55. FakeMouse.Target = io.Target
  56. FakeMouse.Hit = io.Hit
  57. if not io.isMouse then
  58. local b = io.UserInputState == Enum.UserInputState.Begin
  59. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  60. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  61. end
  62. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  63. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  64. end
  65. for _,t in pairs(CAS.Actions) do
  66. for _,k in pairs(t.Keys) do
  67. if k==io.KeyCode then
  68. t.Function(t.Name,io.UserInputState,io)
  69. end
  70. end
  71. end
  72. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  73. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  74. end
  75. end)
  76. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  77. local Mouse = owner:GetMouse()
  78. local UIS = game:GetService("UserInputService")
  79. local input = function(io,RobloxHandled)
  80. if RobloxHandled then return end
  81. --Since InputObject is a client-side instance, we create and pass table instead
  82. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  83. end
  84. UIS.InputBegan:Connect(input)
  85. UIS.InputEnded:Connect(input)
  86. local h,t
  87. --Give the server mouse data every second frame, but only if the values changed
  88. --If player is not moving their mouse, client won't fire events
  89. local HB = game:GetService("RunService").Heartbeat
  90. while true do
  91. if h~=Mouse.Hit or t~=Mouse.Target then
  92. h,t=Mouse.Hit,Mouse.Target
  93. Event:FireServer({isMouse=true,Target=t,Hit=h})
  94. end
  95. --Wait 2 frames
  96. for i=1,2 do
  97. HB:Wait()
  98. end
  99. end]==],script)
  100.  
  101. ----Sandboxed game object that allows the usage of client-side methods and services
  102. --Real game object
  103. local RealGame = game
  104.  
  105. --Metatable for fake service
  106. local FakeService_Metatable = {
  107. __index = function(self,k)
  108. local s = rawget(self,"_RealService")
  109. if s then
  110. return typeof(s[k])=="function"
  111. and function(_,...)return s[k](s,...)end or s[k]
  112. end
  113. end,
  114. __newindex = function(self,k,v)
  115. local s = rawget(self,"_RealService")
  116. if s then s[k]=v end
  117. end
  118. }
  119. local function FakeService(t,RealService)
  120. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  121. return setmetatable(t,FakeService_Metatable)
  122. end
  123.  
  124. --Fake game object
  125. local FakeGame = {
  126. GetService = function(self,s)
  127. return rawget(self,s) or RealGame:GetService(s)
  128. end,
  129. Players = FakeService({
  130. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  131. },"Players"),
  132. UserInputService = FakeService(UIS,"UserInputService"),
  133. ContextActionService = FakeService(CAS,"ContextActionService"),
  134. RunService = FakeService({
  135. _btrs = {},
  136. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  137. BindToRenderStep = function(self,name,_,fun)
  138. self._btrs[name] = self.Heartbeat:Connect(fun)
  139. end,
  140. UnbindFromRenderStep = function(self,name)
  141. self._btrs[name]:Disconnect()
  142. end,
  143. },"RunService")
  144. }
  145. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  146. FakeGame.service = FakeGame.GetService
  147. FakeService(FakeGame,game)
  148. --Changing owner to fake player object to support owner:GetMouse()
  149. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  150. end
  151.  
  152.  
  153. Character = game.Players.LocalPlayer.Character
  154. Player = game.Players.LocalPlayer
  155. char = Character
  156. hum = Character.Humanoid
  157. Torso = Character.Torso
  158. Head = Character.Head
  159.  
  160. char.Shirt.ShirtTemplate = "rbxassetid://994469018"
  161. char.Pants.PantsTemplate = "rbxassetid://977437883"
  162.  
  163.  
  164. local BC = char["Body Colors"]
  165. BC.HeadColor = BrickColor.new("Really black")
  166. BC.LeftArmColor = BrickColor.new("Really black")
  167. BC.LeftLegColor = BrickColor.new("Really black")
  168. BC.RightArmColor = BrickColor.new("Really black")
  169. BC.RightLegColor = BrickColor.new("Really black")
  170. BC.TorsoColor = BrickColor.new("Really black")
  171.  
  172. char.Head.face.Texture = "rbxassetid://701379058"
  173.  
  174. hum.MaxHealth = math.huge
  175.  
  176.  
  177.  
  178.  
  179. for i,v in pairs(char:children()) do
  180. if v:IsA("Hat") then
  181. v:Destroy()
  182. end
  183. end
  184. for i,v in pairs(char:children()) do
  185. if v:IsA("Accessory") then
  186. v:Destroy()
  187. end
  188. end
  189. for i,v in pairs(char:children()) do
  190. if v:IsA("Hair") then
  191. v:Destroy()
  192. end
  193. end
  194. --141378828
  195. Reaper = Instance.new("Model")
  196. Reaper.Parent = Player.Character
  197. Reaper.Name = "Reaper"
  198. rh = Instance.new("Part")
  199. rh.Parent = Reaper
  200. rh.BrickColor = BrickColor.new("Really red")
  201. rh.Locked = true
  202. rh.CanCollide = false
  203. mesh = Instance.new("SpecialMesh")
  204. rh.formFactor = "Symmetric"
  205. mesh.MeshType = "FileMesh"
  206. mesh.MeshId = "http://www.roblox.com/asset/?id=112643970"
  207. mesh.TextureId = "http://www.roblox.com/asset/?id=1018233493"
  208. mesh.Parent = rh
  209. mesh.Scale = Vector3.new(1.1,1.1,1.1)
  210. local weld = Instance.new("Weld")
  211. weld.Parent = rh
  212. rh.Transparency = 0
  213. weld.Part0 = rh
  214. weld.Part1 = Player.Character.Head
  215. weld.C0 = CFrame.new(-0, -0.05, -0)*CFrame.Angles(0, 0, 0)
  216.  
  217. local s = Instance.new("Sound",char)
  218. s.SoundId = "http://www.roblox.com/asset/?id=565420180"
  219. s.Pitch = 1
  220. s.Volume = 2
  221. s.Looped = true
  222. wait(1)
  223. s:play()
  224. local txtfag = Instance.new("BillboardGui", game.Players.LocalPlayer.Character.Head)
  225. txtfag.Adornee = suckadick
  226. txtfag.Name = "kys nigga"
  227. txtfag.Size = UDim2.new(2, 0, 1.2, 0)
  228. txtfag.StudsOffset = Vector3.new(-5, 3, 0)
  229. local textfag = Instance.new("TextLabel", txtfag)
  230. textfag.Size = UDim2.new(6, 0, 1, 0)
  231. textfag.FontSize = "Size8"
  232. textfag.TextScaled = true
  233. textfag.TextTransparency = 0
  234. textfag.BackgroundTransparency = 1
  235. textfag.TextTransparency = 0
  236. textfag.TextStrokeTransparency = 0
  237. textfag.Font = "Cartoon"
  238. textfag.TextStrokeColor3 = Color3.new(0, 0, 0)
  239. textfag.Text = game.Players.LocalPlayer.Character.Name.." "
  240.  
  241.  
  242. local runDummyScript = function(f,scri)
  243. local oldenv = getfenv(f)
  244. local newenv = setmetatable({}, {
  245. __index = function(_, k)
  246. if k:lower() == 'script' then
  247. return scri
  248. else
  249. return oldenv[k]
  250. end
  251. end
  252. })
  253. setfenv(f, newenv)
  254. ypcall(function() f() end)
  255. end
  256. cors = {}
  257. mas = Instance.new("Model",game:GetService("Lighting"))
  258. mas.Name = "CompiledModel"
  259. o1 = Instance.new("Tool")
  260. o2 = Instance.new("Part")
  261. o3 = Instance.new("SpecialMesh")
  262. o4 = Instance.new("Sound")
  263. o5 = Instance.new("Sound")
  264. o6 = Instance.new("Sound")
  265. o7 = Instance.new("PointLight")
  266. o8 = Instance.new("Sound")
  267. o10 = Instance.new("LocalScript")
  268. o11 = Instance.new("Animation")
  269. o12 = Instance.new("ScreenGui")
  270. o13 = Instance.new("Frame")
  271. o14 = Instance.new("TextLabel")
  272. o15 = Instance.new("TextLabel")
  273. o16 = Instance.new("TextLabel")
  274. o17 = Instance.new("Frame")
  275. o18 = Instance.new("Frame")
  276. o19 = Instance.new("Frame")
  277. o20 = Instance.new("Frame")
  278. o21 = Instance.new("ImageLabel")
  279. o22 = Instance.new("TextLabel")
  280. o23 = Instance.new("Frame")
  281. o24 = Instance.new("Frame")
  282. o25 = Instance.new("TextLabel")
  283. o26 = Instance.new("LocalScript")
  284. o1.Name = "AUG"
  285. o1.Parent = game.Players.LocalPlayer.Backpack
  286. o1.TextureId = "http://www.roblox.com/asset/?id=122079912"
  287. o1.GripForward = Vector3.new(-0.242535636, -0, -0.970142484)
  288. o1.GripPos = Vector3.new(0.200000003, -0.400000006, 0.200000003)
  289. o1.GripRight = Vector3.new(0.970142484, 0, -0.242535636)
  290. o1.ToolTip = "Steyr AUG"
  291. o1.CanBeDropped = false
  292. o2.Name = "Handle"
  293. o2.Parent = o1
  294. o2.BrickColor = BrickColor.new("Black")
  295. o2.Position = Vector3.new(15.9000006, -8.5, 3.20000005)
  296. o2.FormFactor = Enum.FormFactor.Custom
  297. o2.Size = Vector3.new(0.200000003, 1, 3.5999999)
  298. o2.CFrame = CFrame.new(15.9000006, -8.5, 3.20000005, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  299. o2.BottomSurface = Enum.SurfaceType.Smooth
  300. o2.TopSurface = Enum.SurfaceType.Smooth
  301. o2.Color = Color3.new(0.105882, 0.164706, 0.207843)
  302. o2.Position = Vector3.new(15.9000006, -8.5, 3.20000005)
  303. o3.Parent = o2
  304. o3.MeshId = "http://www.roblox.com/asset/?id=3824738"
  305. o3.Scale = Vector3.new(1.33000004, 1.33000004, 1.33000004)
  306. o3.TextureId = "http://www.roblox.com/asset?ID=3824735 "
  307. o3.MeshType = Enum.MeshType.FileMesh
  308. o4.Name = "FireSound"
  309. o4.Parent = o2
  310. o4.Pitch = 1.3999999761581
  311. o4.SoundId = "http://www.roblox.com/asset/?id=10209859 "
  312. o4.Volume = 1
  313. o5.Name = "Reload"
  314. o5.Parent = o2
  315. o5.SoundId = "http://www.roblox.com/asset/?id=2691591"
  316. o5.Volume = 1
  317. o6.Name = "EquipSound"
  318. o6.Parent = o2
  319. o6.SoundId = "http://www.roblox.com/asset/?id=10209881"
  320. o6.Volume = 1
  321. o7.Name = "Flash"
  322. o7.Parent = o2
  323. o7.Color = Color3.new(1, 1, 0)
  324. o7.Enabled = false
  325. o7.Brightness = 1.5
  326. o8.Name = "Tick"
  327. o8.Parent = o2
  328. o8.SoundId = "rbxasset://sounds//clickfast.wav"
  329. o8.Volume = 1
  330. o10.Name = "AUG"
  331. o10.Parent = o1
  332. print("Giving "..game.Players.LocalPlayer.Name.. " an " ..o1.Name.. " Don't leak this. If you do i will fucking shoot you till your dead ;\ ")
  333. table.insert(cors,coroutine.create(function()
  334. wait()
  335. runDummyScript(function()
  336. --------------------- TEMPLATE ASSAULT RIFLE WEAPON ---------------------------
  337. -- Waits for the child of the specified parent
  338. local function WaitForChild(parent, childName)
  339. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  340. return parent[childName]
  341. end
  342.  
  343. ----- MAGIC NUMBERS ABOUT THE TOOL -----
  344. -- How much damage a bullet does
  345. local Damage = 65
  346. -- How many times per second the gun can fire
  347. local FireRate = 1 / 15
  348. -- The maximum distance the can can shoot, this value should never go above 1000
  349. local Range = 700
  350. -- In radians the minimum accuracy penalty
  351. local MinSpread = 0.01
  352. -- In radian the maximum accuracy penalty
  353. local MaxSpread = 0.06
  354. -- Number of bullets in a clip
  355. local ClipSize = 30
  356. -- DefaultValue for spare ammo
  357. local SpareAmmo = math.huge
  358. -- The amount the aim will increase or decrease by
  359. -- decreases this number reduces the speed that recoil takes effect
  360. local AimInaccuracyStepAmount = 0.01
  361. -- Time it takes to reload weapon
  362. local ReloadTime = 2.3
  363. ----------------------------------------
  364.  
  365. -- Colors
  366. local FriendlyReticleColor = Color3.new(0, 1, 0)
  367. local EnemyReticleColor = Color3.new(1, 0, 0)
  368. local NeutralReticleColor = Color3.new(1, 1, 1)
  369.  
  370. local Spread = MinSpread
  371. local AmmoInClip = ClipSize
  372.  
  373. local Tool = o1
  374. local Handle = WaitForChild(Tool, 'Handle')
  375. local WeaponGui = nil
  376.  
  377. local LeftButtonDown
  378. local Reloading = false
  379. local IsShooting = false
  380.  
  381. -- Player specific convenience variables
  382. local MyPlayer = nil
  383. local MyCharacter = nil
  384. local MyHumanoid = nil
  385. local MyTorso = nil
  386. local MyMouse = nil
  387.  
  388. local RecoilAnim
  389. local RecoilTrack = nil
  390.  
  391. local IconURL = Tool.TextureId -- URL to the weapon icon asset
  392.  
  393. local DebrisService = game:GetService('Debris')
  394. local PlayersService = game:GetService('Players')
  395.  
  396.  
  397. local FireSound
  398.  
  399. local OnFireConnection = nil
  400. local OnReloadConnection = nil
  401.  
  402. local DecreasedAimLastShot = false
  403. local LastSpreadUpdate = time()
  404.  
  405. -- this is a dummy object that holds the flash made when the gun is fired
  406. local FlashHolder = nil
  407.  
  408.  
  409. local WorldToCellFunction = Workspace.Terrain.WorldToCellPreferSolid
  410. local GetCellFunction = Workspace.Terrain.GetCell
  411.  
  412. function RayIgnoreCheck(hit, pos)
  413. if hit then
  414. if hit.Transparency >= 1 or string.lower(hit.Name) == "water" or
  415. hit.Name == "Effect" or hit.Name == "Rocket" or hit.Name == "Bullet" or
  416. hit.Name == "Handle" or hit:IsDescendantOf(MyCharacter) then
  417. return true
  418. elseif hit:IsA('Terrain') and pos then
  419. local cellPos = WorldToCellFunction(Workspace.Terrain, pos)
  420. if cellPos then
  421. local cellMat = GetCellFunction(Workspace.Terrain, cellPos.x, cellPos.y, cellPos.z)
  422. if cellMat and cellMat == Enum.CellMaterial.Water then
  423. return true
  424. end
  425. end
  426. end
  427. end
  428. return false
  429. end
  430.  
  431. -- @preconditions: vec should be a unit vector, and 0 < rayLength <= 1000
  432. function RayCast(startPos, vec, rayLength)
  433. local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle)
  434. if hitObject and hitPos then
  435. local distance = rayLength - (hitPos - startPos).magnitude
  436. if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
  437. -- there is a chance here for potential infinite recursion
  438. return RayCast(hitPos, vec, distance)
  439. end
  440. end
  441. return hitObject, hitPos
  442. end
  443.  
  444.  
  445.  
  446. function TagHumanoid(humanoid, player)
  447. -- Add more tags here to customize what tags are available.
  448. while humanoid:FindFirstChild('creator') do
  449. humanoid:FindFirstChild('creator'):Destroy()
  450. end
  451. local creatorTag = Instance.new("ObjectValue")
  452. creatorTag.Value = player
  453. creatorTag.Name = "creator"
  454. creatorTag.Parent = humanoid
  455. DebrisService:AddItem(creatorTag, 1.5)
  456.  
  457. local weaponIconTag = Instance.new("StringValue")
  458. weaponIconTag.Value = IconURL
  459. weaponIconTag.Name = "icon"
  460. weaponIconTag.Parent = creatorTag
  461. end
  462.  
  463.  
  464. local function CreateBullet(bulletPos)
  465. local bullet = Instance.new('Part', Workspace)
  466. bullet.FormFactor = Enum.FormFactor.Custom
  467. bullet.Size = Vector3.new(0.1, 0.1, 0.1)
  468. bullet.BrickColor = BrickColor.new("Black")
  469. bullet.Shape = Enum.PartType.Block
  470. bullet.CanCollide = false
  471. bullet.CFrame = CFrame.new(bulletPos)
  472. bullet.Anchored = true
  473. bullet.TopSurface = Enum.SurfaceType.Smooth
  474. bullet.BottomSurface = Enum.SurfaceType.Smooth
  475. bullet.Name = 'Bullet'
  476. DebrisService:AddItem(bullet, 2.5)
  477. return bullet
  478. end
  479.  
  480. local function Reload()
  481. if not Reloading then
  482. Reloading = true
  483. -- Don't reload if you are already full or have no extra ammo
  484. if AmmoInClip ~= ClipSize and SpareAmmo > 0 then
  485. if RecoilTrack then
  486. RecoilTrack:Stop()
  487. end
  488. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
  489. if WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
  490. WeaponGui.Crosshair.ReloadingLabel.Visible = true
  491. end
  492. end
  493. script.Parent.Handle.Reload:Play()
  494. wait(ReloadTime)
  495. -- Only use as much ammo as you have
  496. local ammoToUse = math.min(ClipSize - AmmoInClip, SpareAmmo)
  497. AmmoInClip = AmmoInClip + ammoToUse
  498. SpareAmmo = SpareAmmo - ammoToUse
  499. UpdateAmmo(AmmoInClip)
  500. WeaponGui.Reload.Visible = false
  501. end
  502. Reloading = false
  503. end
  504. end
  505.  
  506. function OnFire()
  507. if IsShooting then return end
  508. if MyHumanoid and MyHumanoid.Health > 0 then
  509. if RecoilTrack and AmmoInClip > 0 then
  510. RecoilTrack:Play()
  511. end
  512. IsShooting = true
  513. while LeftButtonDown and AmmoInClip > 0 and not Reloading do
  514. if Spread and not DecreasedAimLastShot then
  515. Spread = math.min(MaxSpread, Spread + AimInaccuracyStepAmount)
  516. UpdateCrosshair(Spread)
  517. end
  518. DecreasedAimLastShot = not DecreasedAimLastShot
  519. if Handle:FindFirstChild('FireSound') then
  520. Handle.FireSound:Play()
  521. Handle.Flash.Enabled = true
  522. end
  523. if MyMouse then
  524. local targetPoint = MyMouse.Hit.p
  525. local shootDirection = (targetPoint - Handle.Position).unit
  526. -- Adjust the shoot direction randomly off by a little bit to account for recoil
  527. shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
  528. (0.5 - math.random()) * 2 * Spread,
  529. (0.5 - math.random()) * 2 * Spread) * shootDirection
  530. local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
  531. local bullet
  532. -- Create a bullet here
  533. if hitObject then
  534. bullet = CreateBullet(bulletPos)
  535. end
  536. if hitObject and hitObject.Parent then
  537. local hitHumanoid = hitObject.Parent:FindFirstChild("Humanoid")
  538. if hitHumanoid then
  539. local hitPlayer = game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)
  540. if MyPlayer.Neutral or hitPlayer then
  541. TagHumanoid(hitHumanoid, MyPlayer)
  542. hitHumanoid:TakeDamage(Damage)
  543. if bullet then
  544. bullet:Destroy()
  545. bullet = nil
  546. --bullet.Transparency = 1
  547. end
  548. Spawn(UpdateTargetHit)
  549. end
  550. end
  551. end
  552.  
  553. AmmoInClip = AmmoInClip - 1
  554. UpdateAmmo(AmmoInClip)
  555. end
  556. wait(FireRate)
  557. end
  558. Handle.Flash.Enabled = false
  559. IsShooting = false
  560. if AmmoInClip == 0 then
  561. Handle.Tick:Play()
  562. WeaponGui.Reload.Visible = true
  563. end
  564. if RecoilTrack then
  565. RecoilTrack:Stop()
  566. end
  567. end
  568. end
  569.  
  570. local TargetHits = 0
  571. function UpdateTargetHit()
  572. TargetHits = TargetHits + 1
  573. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
  574. WeaponGui.Crosshair.TargetHitImage.Visible = true
  575. end
  576. wait(0.5)
  577. TargetHits = TargetHits - 1
  578. if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
  579. WeaponGui.Crosshair.TargetHitImage.Visible = false
  580. end
  581. end
  582.  
  583. function UpdateCrosshair(value, mouse)
  584. if WeaponGui then
  585. local absoluteY = 650
  586. WeaponGui.Crosshair:TweenSize(
  587. UDim2.new(0, value * absoluteY * 2 + 23, 0, value * absoluteY * 2 + 23),
  588. Enum.EasingDirection.Out,
  589. Enum.EasingStyle.Linear,
  590. 0.33)
  591. end
  592. end
  593.  
  594. function UpdateAmmo(value)
  595. if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
  596. WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
  597. if value > 0 and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
  598. WeaponGui.Crosshair.ReloadingLabel.Visible = false
  599. end
  600. end
  601. if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
  602. WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
  603. end
  604. end
  605.  
  606.  
  607. function OnMouseDown()
  608. LeftButtonDown = true
  609. OnFire()
  610. end
  611.  
  612. function OnMouseUp()
  613. LeftButtonDown = false
  614. end
  615.  
  616. function OnKeyDown(key)
  617. if string.lower(key) == 'r' then
  618. Reload()
  619. end
  620. end
  621.  
  622.  
  623. function OnEquipped(mouse)
  624. Handle.EquipSound:Play()
  625. RecoilAnim = WaitForChild(Tool, 'Recoil')
  626. FireSound = WaitForChild(Handle, 'FireSound')
  627.  
  628. MyCharacter = Tool.Parent
  629. MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
  630. MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
  631. MyTorso = MyCharacter:FindFirstChild('Torso')
  632. MyMouse = mouse
  633. WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()
  634. if WeaponGui and MyPlayer then
  635. WeaponGui.Parent = MyPlayer.PlayerGui
  636. UpdateAmmo(AmmoInClip)
  637. end
  638. if RecoilAnim then
  639. RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
  640. end
  641.  
  642. if MyMouse then
  643. -- Disable mouse icon
  644. MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
  645. MyMouse.Button1Down:connect(OnMouseDown)
  646. MyMouse.Button1Up:connect(OnMouseUp)
  647. MyMouse.KeyDown:connect(OnKeyDown)
  648. end
  649. end
  650.  
  651.  
  652. -- Unequip logic here
  653. function OnUnequipped()
  654. LeftButtonDown = false
  655. Reloading = false
  656. MyCharacter = nil
  657. MyHumanoid = nil
  658. MyTorso = nil
  659. MyPlayer = nil
  660. MyMouse = nil
  661. if OnFireConnection then
  662. OnFireConnection:disconnect()
  663. end
  664. if OnReloadConnection then
  665. OnReloadConnection:disconnect()
  666. end
  667. if FlashHolder then
  668. FlashHolder = nil
  669. end
  670. if WeaponGui then
  671. WeaponGui.Parent = nil
  672. WeaponGui = nil
  673. end
  674. if RecoilTrack then
  675. RecoilTrack:Stop()
  676. end
  677. end
  678.  
  679. local function SetReticleColor(color)
  680. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
  681. for _, line in pairs(WeaponGui.Crosshair:GetChildren()) do
  682. if line:IsA('Frame') then
  683. line.BorderColor3 = color
  684. end
  685. end
  686. end
  687. end
  688.  
  689.  
  690. Tool.Equipped:connect(OnEquipped)
  691. Tool.Unequipped:connect(OnUnequipped)
  692.  
  693. while true do
  694. wait(0.033)
  695. if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and MyMouse then
  696. WeaponGui.Crosshair.Position = UDim2.new(0, MyMouse.X, 0, MyMouse.Y)
  697. SetReticleColor(NeutralReticleColor)
  698.  
  699. local target = MyMouse.Target
  700. if target and target.Parent then
  701. local player = PlayersService:GetPlayerFromCharacter(target.Parent)
  702. if player then
  703. if MyPlayer.Neutral or player.TeamColor ~= MyPlayer.TeamColor then
  704. SetReticleColor(EnemyReticleColor)
  705. else
  706. SetReticleColor(FriendlyReticleColor)
  707. end
  708. end
  709. end
  710. end
  711. if Spread and not IsShooting then
  712. local currTime = time()
  713. if currTime - LastSpreadUpdate > FireRate * 2 then
  714. LastSpreadUpdate = currTime
  715. Spread = math.max(MinSpread, Spread - AimInaccuracyStepAmount)
  716. UpdateCrosshair(Spread, MyMouse)
  717. end
  718. end
  719. end
  720.  
  721. end,o10)
  722. end))
  723. o11.Name = "Recoil"
  724. o11.Parent = o1
  725. o11.AnimationId = "http://www.roblox.com/Asset?ID=94331086"
  726. o12.Name = "WeaponHud"
  727. o12.Parent = o1
  728. o13.Name = "AmmoHud"
  729. o13.Parent = o12
  730. o13.Position = UDim2.new(1,-265,1,-60)
  731. o13.Size = UDim2.new(0,200,0,50)
  732. o13.Style = Enum.FrameStyle.RobloxSquare
  733. o13.Position = UDim2.new(1,-265,1,-60)
  734. o13.BackgroundTransparency = 1
  735. o13.BorderSizePixel = 0
  736. o14.Name = "ForwardSlash"
  737. o14.Parent = o13
  738. o14.Position = UDim2.new(0.5,0,0.5,0)
  739. o14.Text = "/"
  740. o14.Position = UDim2.new(0.5,0,0.5,0)
  741. o14.BackgroundTransparency = 1
  742. o14.BorderSizePixel = 0
  743. o14.FontSize = Enum.FontSize.Size24
  744. o14.TextColor3 = Color3.new(1, 1, 1)
  745. o14.TextStrokeTransparency = 0
  746. o15.Name = "ClipAmmo"
  747. o15.Parent = o13
  748. o15.Position = UDim2.new(0.44999998807907,0,0.5,0)
  749. o15.Text = "54"
  750. o15.Position = UDim2.new(0.44999998807907,0,0.5,0)
  751. o15.BackgroundTransparency = 1
  752. o15.BorderSizePixel = 0
  753. o15.FontSize = Enum.FontSize.Size24
  754. o15.TextColor3 = Color3.new(1, 1, 1)
  755. o15.TextStrokeTransparency = 0
  756. o15.TextXAlignment = Enum.TextXAlignment.Right
  757. o16.Name = "TotalAmmo"
  758. o16.Parent = o13
  759. o16.Position = UDim2.new(0.55000001192093,0,0.5,0)
  760. o16.Text = "180"
  761. o16.Position = UDim2.new(0.55000001192093,0,0.5,0)
  762. o16.BackgroundTransparency = 1
  763. o16.BorderSizePixel = 0
  764. o16.FontSize = Enum.FontSize.Size24
  765. o16.TextColor3 = Color3.new(1, 1, 1)
  766. o16.TextStrokeTransparency = 0
  767. o16.TextXAlignment = Enum.TextXAlignment.Left
  768. o17.Name = "Crosshair"
  769. o17.Parent = o12
  770. o17.Position = UDim2.new(0,500,0,500)
  771. o17.Size = UDim2.new(0,150,0,150)
  772. o17.Position = UDim2.new(0,500,0,500)
  773. o17.BackgroundColor3 = Color3.new(0, 1, 0)
  774. o17.BackgroundTransparency = 1
  775. o17.BorderSizePixel = 0
  776. o18.Name = "TopFrame"
  777. o18.Parent = o17
  778. o18.Position = UDim2.new(0,-1,-0.5,-7)
  779. o18.Size = UDim2.new(0,2,0,14)
  780. o18.Position = UDim2.new(0,-1,-0.5,-7)
  781. o18.BackgroundColor3 = Color3.new(1, 1, 1)
  782. o18.BorderColor3 = Color3.new(0, 0, 0)
  783. o19.Name = "RightFrame"
  784. o19.Parent = o17
  785. o19.Position = UDim2.new(0.5,-7,0,-1)
  786. o19.Size = UDim2.new(0,14,0,2)
  787. o19.Position = UDim2.new(0.5,-7,0,-1)
  788. o19.BackgroundColor3 = Color3.new(1, 1, 1)
  789. o19.BorderColor3 = Color3.new(0, 0, 0)
  790. o20.Name = "LeftFrame"
  791. o20.Parent = o17
  792. o20.Position = UDim2.new(-0.5,-7,0,-1)
  793. o20.Size = UDim2.new(0,14,0,2)
  794. o20.Position = UDim2.new(-0.5,-7,0,-1)
  795. o20.BackgroundColor3 = Color3.new(1, 1, 1)
  796. o20.BorderColor3 = Color3.new(0, 0, 0)
  797. o21.Name = "TargetHitImage"
  798. o21.Parent = o17
  799. o21.Position = UDim2.new(0,-25,0,-25)
  800. o21.Size = UDim2.new(0,50,0,50)
  801. o21.Position = UDim2.new(0,-25,0,-25)
  802. o21.Visible = false
  803. o21.BackgroundTransparency = 1
  804. o21.BorderSizePixel = 0
  805. o21.Image = "http://www.roblox.com/asset/?id=115400215"
  806. o22.Name = "ReloadingLabel"
  807. o22.Parent = o17
  808. o22.Position = UDim2.new(0,20,0,-20)
  809. o22.Text = "Reloading"
  810. o22.Position = UDim2.new(0,20,0,-20)
  811. o22.Visible = false
  812. o22.BackgroundTransparency = 1
  813. o22.BorderSizePixel = 0
  814. o22.Font = Enum.Font.ArialBold
  815. o22.FontSize = Enum.FontSize.Size18
  816. o22.TextColor3 = Color3.new(1, 1, 1)
  817. o22.TextStrokeTransparency = 0
  818. o22.TextXAlignment = Enum.TextXAlignment.Left
  819. o22.TextYAlignment = Enum.TextYAlignment.Bottom
  820. o23.Name = "BottomFrame"
  821. o23.Parent = o17
  822. o23.Position = UDim2.new(0,-1,0.5,-7)
  823. o23.Size = UDim2.new(0,2,0,14)
  824. o23.Position = UDim2.new(0,-1,0.5,-7)
  825. o23.BackgroundColor3 = Color3.new(1, 1, 1)
  826. o23.BorderColor3 = Color3.new(0, 0, 0)
  827. o24.Name = "Reload"
  828. o24.Parent = o12
  829. o24.Position = UDim2.new(1,-265,1,-120)
  830. o24.Size = UDim2.new(0,200,0,50)
  831. o24.Position = UDim2.new(1,-265,1,-120)
  832. o24.Visible = false
  833. o24.BackgroundTransparency = 1
  834. o24.BorderSizePixel = 0
  835. o25.Name = "Reload"
  836. o25.Parent = o24
  837. o25.Position = UDim2.new(0.5,0,0.5,0)
  838. o25.Text = "Press R to Reload"
  839. o25.Position = UDim2.new(0.5,0,0.5,0)
  840. o25.BackgroundTransparency = 1
  841. o25.BorderSizePixel = 0
  842. o25.Font = Enum.Font.ArialBold
  843. o25.FontSize = Enum.FontSize.Size24
  844. o25.TextColor3 = Color3.new(1, 0, 0)
  845. o25.TextStrokeTransparency = 0
  846. o26.Name = "ArmWeld [Rifle]"
  847. o26.Parent = o1
  848. table.insert(cors,coroutine.create(function()
  849. wait()
  850. runDummyScript(function()
  851. Tool = script.Parent;
  852.  
  853. local arms = nil
  854. local torso = nil
  855. local welds = {}
  856.  
  857. function Equip(mouse)
  858. wait(0.01)
  859. arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
  860. torso = Tool.Parent:FindFirstChild("Torso")
  861. if arms ~= nil and torso ~= nil then
  862. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  863. if sh ~= nil then
  864. local yes = true
  865. if yes then
  866. yes = false
  867. sh[1].Part1 = nil
  868. sh[2].Part1 = nil
  869. local weld1 = Instance.new("Weld")
  870. weld1.Part0 = torso
  871. weld1.Parent = torso
  872. weld1.Part1 = arms[1]
  873. weld1.C1 = CFrame.new(-.1, 1.25, .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
  874. welds[1] = weld1
  875. weld1.Name = "weld1"
  876. local weld2 = Instance.new("Weld")
  877. weld2.Part0 = torso
  878. weld2.Parent = torso
  879. weld2.Part1 = arms[2]
  880. weld2.C1 = CFrame.new(-1, -0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0) --- Same as top
  881. welds[2] = weld2
  882. weld2.Name = "weld2"
  883. end
  884. else
  885. print("sh")
  886. end
  887. else
  888. print("arms")
  889. end
  890. end
  891.  
  892. function Unequip(mouse)
  893. if arms ~= nil and torso ~= nil then
  894. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  895. if sh ~= nil then
  896. local yes = true
  897. if yes then
  898. yes = false
  899. sh[1].Part1 = arms[1]
  900. sh[2].Part1 = arms[2]
  901. welds[1].Parent = nil
  902. welds[2].Parent = nil
  903. end
  904. else
  905. print("sh")
  906. end
  907. else
  908. print("arms")
  909. end
  910. end
  911. Tool.Equipped:connect(Equip)
  912. Tool.Unequipped:connect(Unequip)
  913.  
  914. end,o26)
  915. end))
  916. mas.Parent = workspace
  917. mas:MakeJoints()
  918. local mas1 = mas:GetChildren()
  919. for i=1,#mas1 do
  920. mas1[i].Parent = workspace
  921. ypcall(function() mas1[i]:MakeJoints() end)
  922. end
  923. mas:Destroy()
  924. for i=1,#cors do
  925. coroutine.resume(cors[i])
  926. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement