Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. local gun = {}
  2. local model
  3. local runs = game:GetService("RunService")
  4. local player = game.Players.LocalPlayer
  5. local character = player.Character
  6. local uis = game:GetService("UserInputService")
  7. local camera =workspace.CurrentCamera
  8. local speed = character.Humanoid.WalkSpeed/2
  9. local distance = 0
  10.  
  11. local modes = {"AUTO","SEMI"}
  12.  
  13. local stats = {}
  14.  
  15. stats.Reloading = false
  16. stats.Aiming = false
  17. stats.Sprinting = false
  18. stats.Walking = false
  19. stats.Busy = false
  20. stats.MaxAmmo = 31
  21. stats.MaxMagazines = 6
  22. stats.Ammo = 30
  23. stats.Magazines = 6
  24. stats.gunName = "AK-74M"
  25. stats.fireMode = modes[1]
  26.  
  27. stats.holdcf = CFrame.new(0.2,0,3.6)*CFrame.Angles(0,0,0)
  28. stats.aimcf = CFrame.new(0,0,3.6)*CFrame.Angles(0,0,0)
  29. stats.runcf = CFrame.new(0,0,0)*CFrame.Angles(0,0,0)
  30.  
  31. local Main = stats.holdcf
  32. local Walk = CFrame.new()
  33. local WalkCF = CFrame.new()
  34.  
  35. function walks(rs)
  36.  
  37. speed = speed*0.85+((character.HumanoidRootPart.Velocity*Vector3.new(1, 0, 1)).magnitude)*0.14
  38. distance = distance + speed * rs
  39. local Offset = speed/(character.Humanoid.WalkSpeed*20)
  40. Walk = CFrame.new(math.sin(distance/2)*Offset/4, math.sin(distance)*Offset/8, 0)
  41.  
  42. end
  43.  
  44. function cframes()
  45. if model ~= nil then
  46.  
  47. if model.PrimaryPart == nil then
  48.  
  49. else
  50. model.PrimaryPart.CFrame = camera.CFrame*Main*Walk
  51.  
  52. if not stats.Sprinting and not stats.Aiming then
  53. Main = Main:lerp(stats.holdcf,.1)
  54. character.Humanoid.WalkSpeed = 12
  55.  
  56. end
  57.  
  58. if stats.Sprinting and not stats.Aiming then
  59. Main = Main:lerp(stats.runcf,.1)
  60. character.Humanoid.WalkSpeed = 20
  61. end
  62.  
  63. if not stats.Sprinting and stats.Aiming then
  64. Main = Main:lerp(stats.aimcf,.1)
  65. character.Humanoid.WalkSpeed = 6
  66. end
  67.  
  68. end
  69. end
  70. end
  71. runs.RenderStepped:Connect(function(rs)
  72. walks(rs)
  73. cframes()
  74.  
  75. if character.Head:FindFirstChild("Running") ~= nil then
  76. local walksound = character.Head:FindFirstChild("Running")
  77. walksound.SoundId = "rbxassetid://344520856"
  78. walksound.PlaybackSpeed = 1.2
  79. walksound.Volume = 0
  80. end
  81.  
  82. end)
  83. gun.makeGun = function()
  84.  
  85. for i, mod in pairs(camera:GetChildren()) do
  86. if mod ~= script.Name then
  87. mod:Destroy()
  88. wait()
  89. end
  90. end
  91.  
  92. model = script.AK74M:Clone()
  93. model.Parent = camera
  94. local hold = Instance.new("Animation")
  95. hold.AnimationId = "rbxassetid://3484380339"
  96. local playhold = model.hum:LoadAnimation(hold)
  97. playhold:Play()
  98.  
  99. end
  100.  
  101. uis.InputBegan:Connect(function(i,v)
  102. if not v then
  103. if i.UserInputType == Enum.UserInputType.MouseButton2 then
  104. stats.Aiming = true
  105. uis.MouseIconEnabled = false
  106. end
  107.  
  108. end
  109. end)
  110.  
  111. uis.InputEnded:Connect(function(i,v)
  112. if not v then
  113. if i.UserInputType == Enum.UserInputType.MouseButton2 then
  114. stats.Aiming = false
  115. uis.MouseIconEnabled = true
  116. end
  117.  
  118. end
  119. end)
  120.  
  121. return gun
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement