SHARE
TWEET

RifleScript

tahtsFunny Jun 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --SynapseX Decompiler
  2.  
  3. local Player = game.Players.LocalPlayer
  4. repeat
  5.     wait()
  6. until Player.Character ~= nil
  7. repeat
  8.     wait()
  9. until Player:findFirstChild("PlayerGui") ~= nil
  10. local IS = game:GetService("UserInputService")
  11. local Camera = workspace.CurrentCamera
  12. local Mouse = Player:GetMouse()
  13. local Char = Player.Character
  14. local Torso = Char:WaitForChild("UpperTorso")
  15. local Humanoid = Char:WaitForChild("Humanoid")
  16. local Handle = script.Parent:WaitForChild("Handle")
  17. local RecoilAmount = Player.PlayerScripts:WaitForChild("Client"):WaitForChild("Recoil")
  18. local Modules = game.ReplicatedStorage:WaitForChild("Modules")
  19. local WC = require(Modules:WaitForChild("WeaponCore"))
  20. local Aiming = Char:WaitForChild("Aiming")
  21. local WeaponHUD = Player.PlayerGui:WaitForChild("MainGUI"):WaitForChild("StatsHUD"):WaitForChild("WeaponHUD")
  22. local Crosshair = Player.PlayerGui:WaitForChild("CrosshairGUI"):WaitForChild("Center")
  23. local MouseDown = false
  24. local Mobile = false
  25. local ShootButton
  26. if IS.TouchEnabled then
  27.     Mobile = true
  28.     ShootButton = Player.PlayerGui:WaitForChild("TouchGui"):WaitForChild("TouchControlFrame"):WaitForChild("ShootButton")
  29.     ShootButton.Changed:connect(function()
  30.         if ShootButton.Image == "rbxassetid://2568914327" then
  31.             MouseDown = true
  32.         else
  33.             MouseDown = false
  34.         end
  35.     end)
  36. end
  37. local Db = false
  38. local Reloading = false
  39. local Equipped
  40. local Ammo = 40
  41. local FireRate = 0.08
  42. local Damage = 4
  43. local Spread = 3.2
  44. local Recoil = 4
  45. local Clip = Ammo
  46. local Handle = script.Parent:WaitForChild("Handle")
  47. local GunName = script.Parent.Name
  48. local Anims = {}
  49. function StopAnimations()
  50.     for _, v in ipairs(Anims) do
  51.         if Anims ~= nil then
  52.             v:Stop()
  53.         end
  54.     end
  55.     Anims = {}
  56. end
  57. function LoadAnimation(id)
  58.     local animation = Instance.new("Animation", Humanoid)
  59.     animation.AnimationId = "http://www.roblox.com/Asset?ID=" .. id
  60.     local animTrack = Humanoid:LoadAnimation(animation)
  61.     animTrack:Play()
  62.     animTrack:Stop()
  63. end
  64. function PlayAnimation(id, t)
  65.     local animation = Instance.new("Animation", Humanoid)
  66.     animation.AnimationId = "http://www.roblox.com/Asset?ID=" .. id
  67.     local animTrack = Humanoid:LoadAnimation(animation)
  68.     animTrack:Play()
  69.     table.insert(Anims, animTrack)
  70.     local finished = false
  71.     animTrack.Stopped:connect(function()
  72.         finished = true
  73.     end)
  74.     repeat
  75.         wait()
  76.     until finished
  77.     animTrack = nil
  78.     animation:Destroy()
  79. end
  80. local GetSkin = game.ReplicatedStorage.RemoteFunction:InvokeServer("GetSkin", script.Parent.Name)
  81. if GetSkin then
  82. else
  83.     print("Failed to get skin [" .. script.Parent.Name .. "]")
  84. end
  85. LoadAnimation(1233834240)
  86. LoadAnimation(1233836139)
  87. LoadAnimation(1234743288)
  88. LoadAnimation(1241157703)
  89. LoadAnimation(1241010205)
  90. function Reload()
  91.     if Equipped and not Db and Ammo ~= Clip and not Reloading and Humanoid.Health > 0 then
  92.         Reloading = true
  93.         WC.PlaySound(Char, 174295321, Torso)
  94.         WC.MagReload(Char, Handle)
  95.         spawn(function()
  96.             wait(1.2)
  97.             WC.PlaySound(Char, 506273075, Torso)
  98.         end)
  99.         PlayAnimation(1241157703)
  100.         Ammo = Clip
  101.         WeaponHUD.Ammo.Ammo1.Text = Ammo
  102.         WeaponHUD.Ammo.Ammo2.Text = Clip
  103.         wait(0.1)
  104.         Reloading = false
  105.     end
  106. end
  107. function GetMousePoint(X, Y)
  108.     local ignore = {
  109.         workspace.Ignore,
  110.         Char,
  111.         workspace.Water
  112.     }
  113.     local Mag = Camera:ScreenPointToRay(X, Y)
  114.     local NewRay = Ray.new(Mag.Origin, Mag.Direction * 2000)
  115.     local Target, Position = workspace:FindPartOnRayWithIgnoreList(NewRay, ignore, false, true)
  116.     return Position
  117. end
  118. function RayCheck()
  119.     local ignore = {
  120.         workspace.Ignore,
  121.         Char,
  122.         workspace.Water
  123.     }
  124.     local Pos = Handle.CFrame * CFrame.new(0, 0.25, 1.5)
  125.     local ray = Ray.new(Pos.p, (Mouse.Hit.p - Pos.p).unit * 2.5)
  126.     local part, position = workspace:FindPartOnRayWithIgnoreList(ray, ignore, false, true)
  127.     if part then
  128.         return false
  129.     else
  130.         return true
  131.     end
  132. end
  133. if not Mobile then
  134.     IS.InputBegan:connect(function(input, chatting)
  135.         if Equipped then
  136.             if input.UserInputType == Enum.UserInputType.Keyboard and not chatting and input.KeyCode == Enum.KeyCode.R then
  137.                 Reload()
  138.             end
  139.             if input.UserInputType == Enum.UserInputType.Touch and not chatting and input.Key then
  140.                 Reload()
  141.             end
  142.             if input.UserInputType == Enum.UserInputType.Gamepad1 then
  143.                 if input.KeyCode == Enum.KeyCode.ButtonX then
  144.                     Reload()
  145.                 end
  146.                 if input.KeyCode == Enum.KeyCode.ButtonR2 and Equipped and not Reloading and not Db then
  147.                     MouseDown = true
  148.                     Running = false
  149.                 end
  150.             end
  151.         end
  152.     end)
  153.     IS.InputEnded:connect(function(input, chatting)
  154.         if input.UserInputType == Enum.UserInputType.Keyboard then
  155.         end
  156.         if input.UserInputType == Enum.UserInputType.Gamepad1 and input.KeyCode == Enum.KeyCode.ButtonR2 then
  157.             MouseDown = false
  158.             Running = false
  159.         end
  160.     end)
  161.     Mouse.Button1Down:connect(function()
  162.         if Equipped and not Reloading and not Db then
  163.             MouseDown = true
  164.             Running = false
  165.         end
  166.     end)
  167.     Mouse.Button1Up:connect(function()
  168.         if Equipped and not Db then
  169.             Db = true
  170.             MouseDown = false
  171.             Db = false
  172.         end
  173.     end)
  174. end
  175. spawn(function()
  176.     while true do
  177.         while true do
  178.             wait(FireRate)
  179.             if MouseDown and not Reloading and Equipped and not Running and Humanoid.Health > 0 and Aiming.Value and RayCheck() then
  180.                 if Ammo > 0 then
  181.                     RecoilAmount.Value = Vector3.new(math.random(-Recoil, Recoil) / 100, Recoil / 100, math.random(-Recoil, Recoil) / 100)
  182.                     Ammo = Ammo - 1
  183.                     WeaponHUD.Ammo.Ammo1.Text = Ammo
  184.                     WeaponHUD.Ammo.Ammo2.Text = Clip
  185.                     WC.PlaySound(Char, 1772743949, Torso)
  186.                     WC.ShootGun(Char, Char, GetMousePoint(Crosshair.AbsolutePosition.X, Crosshair.AbsolutePosition.Y), GunName, Damage, Spread)
  187.                     spawn(function()
  188.                         PlayAnimation(1241010205, true)
  189.                     end)
  190.                 end
  191.             end
  192.         end
  193.         Reload()
  194.     end
  195. end)
  196. script.Parent.Equipped:connect(function()
  197.     if ShootButton then
  198.         ShootButton.Visible = true
  199.     end
  200.     WeaponHUD.Visible = true
  201.     WeaponHUD.Weapon.Icon.Image = script.Parent.TextureId
  202.     WeaponHUD.Ammo.TextLabel.Text = script.Parent.Name
  203.     WeaponHUD.Ammo.Ammo1.Text = Ammo
  204.     WeaponHUD.Ammo.Ammo2.Text = Clip
  205.     WeaponHUD.Ammo.Slash.Visible = true
  206.     WC.Equip(Char, Char, Handle)
  207.     WC.PlaySound(Char, 153647514, Torso)
  208.     Mouse.TargetFilter = workspace.Ignore
  209.     PlayAnimation(1233834240)
  210.     if Char:findFirstChild(GunName) then
  211.         Equipped = true
  212.         PlayAnimation(1240868684)
  213.     end
  214. end)
  215. script.Parent.Unequipped:connect(function()
  216.     if ShootButton then
  217.         ShootButton.Visible = false
  218.     end
  219.     MouseDown = false
  220.     WeaponHUD.Visible = false
  221.     StopAnimations()
  222.     Equipped = false
  223.     WC.PlaySound(Char, 153647514, Torso)
  224.     if not Char:findFirstChild("Crawling") then
  225.         PlayAnimation(1233836139, true)
  226.     end
  227.     StopAnimations()
  228. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top