Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.80 KB | None | 0 0
  1. --TitanEngine
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = game.Players.LocalPlayer.Character
  5. local camera = workspace.CurrentCamera
  6. local storage = game.ReplicatedStorage.Resources.Client
  7. --
  8. local runs = game:GetService("RunService")
  9. local uis = game:GetService("UserInputService")
  10. --
  11. local main = CFrame.new()
  12. local walkcf = CFrame.new()
  13. local breath = CFrame.new()
  14. local state = "Idle"
  15. --
  16. local firing = false
  17. local reloading = false
  18. local aiming = false
  19. local busy = false
  20. local running = false
  21. local walking = false
  22. local isbreath = 1
  23. local iswalk = 2
  24. local walkoffset = 0.2
  25. --
  26. local stepwait = 12
  27. local stepwalk = 0.1
  28. --
  29. local guns = {"AKS-74U"}
  30. local gun = guns[1]
  31. local gunModel = storage.Weapons:FindFirstChild(gun):Clone()
  32. local mainpart = gunModel.PrimaryPart
  33. local data = require(storage.Module:FindFirstChild(gun):Clone())
  34.  
  35. repeat wait() until mainpart
  36.  
  37. for i,parts in pairs(gunModel:GetChildren()) do
  38. if parts ~= gunModel.PrimaryPart then
  39. local gunWeld = Instance.new("ManualWeld",parts)
  40. gunWeld.Part0 = gunModel.PrimaryPart
  41. gunWeld.Part1 = parts
  42. gunWeld.C1 = parts.CFrame:inverse()*gunWeld.Part0.CFrame
  43. gunWeld.Name = parts.Name.."Weld"
  44. gunModel.Parent = camera
  45. parts.Anchored = false
  46. parts.CanCollide = false
  47. end
  48. end
  49.  
  50. uis.InputBegan:Connect(function(input,process)
  51. if not process then
  52. if input.KeyCode == Enum.KeyCode.A then
  53. if state ~= "Right" then
  54. state = "Left"
  55. end
  56. end
  57. if input.KeyCode == Enum.KeyCode.D then
  58. if state ~= "Left" then
  59. state = "Right"
  60. end
  61. end
  62.  
  63. end
  64. end)
  65.  
  66. uis.InputEnded:Connect(function(input,process)
  67. if not process then
  68. if input.KeyCode == Enum.KeyCode.A then
  69. if state ~= "Right" then
  70. state = "Idle"
  71. end
  72. end
  73. if input.KeyCode == Enum.KeyCode.D then
  74. if state ~= "Left" then
  75. state = "Idle"
  76. end
  77. end
  78.  
  79. end
  80. end)
  81.  
  82. character.Humanoid.Running:Connect(function(s)
  83. if s > 1 then
  84. walking = true
  85. character.Humanoid.WalkSpeed = 20
  86. else
  87. walking = false
  88. character.Humanoid.WalkSpeed = 16
  89. end
  90. end)
  91.  
  92. function positionSettings()
  93. local gunpos = data.main
  94. mainpart.CFrame = camera.CFrame*gunpos*main*breath
  95.  
  96.  
  97. if state == "Left" then
  98. main = main:lerp(CFrame.Angles(0,0,math.rad(10)),.1)
  99. end
  100.  
  101. if state == "Right" then
  102. main = main:lerp(CFrame.Angles(0,0,math.rad(-10)),.1)
  103. end
  104.  
  105. breath = breath:lerp(CFrame.new(),.1)
  106. main = main:lerp(CFrame.new(),.1)
  107.  
  108. if not walking then
  109. if isbreath == 1 then
  110. breath = breath:lerp(breath*CFrame.new(0,0.01,0),.1)
  111. end
  112. if isbreath == 2 then
  113. breath = breath:lerp(breath*CFrame.new(0,0.015,0),.1)
  114. end
  115. if isbreath == 3 then
  116. breath = breath:lerp(breath*CFrame.new(0,0.02,0),.1)
  117. end
  118. if isbreath == 4 then
  119. breath = breath:lerp(breath*CFrame.new(0,0.025,0),.1)
  120. end
  121. if isbreath == 5 then
  122. breath = breath:lerp(breath*CFrame.new(0,0.03,0),.1)
  123. end
  124. if isbreath == 6 then
  125. breath = breath:lerp(breath*CFrame.new(0,0.025,0),.1)
  126. end
  127. if isbreath == 7 then
  128. breath = breath:lerp(breath*CFrame.new(0,0.02,0),.1)
  129. end
  130. if isbreath == 8 then
  131. breath = breath:lerp(breath*CFrame.new(0,0.015,0),.1)
  132. end
  133. if isbreath == 9 then
  134. breath = breath:lerp(breath*CFrame.new(0,0.01,0),.1)
  135. end
  136.  
  137. else
  138.  
  139. if iswalk == 1 then
  140. breath = breath:lerp(breath*CFrame.new(0,0,0)*CFrame.Angles(0,math.rad(0),0),walkoffset)
  141. end
  142. if iswalk == 2 then
  143. breath = breath:lerp(breath*CFrame.new(0.01,0.005,0)*CFrame.Angles(0,math.rad(0.1),0),walkoffset)
  144. end
  145. if iswalk == 3 then
  146. breath = breath:lerp(breath*CFrame.new(0.015,0.01,0)*CFrame.Angles(0,math.rad(0.2),0),walkoffset)
  147. end
  148. if iswalk == 4 then
  149. breath = breath:lerp(breath*CFrame.new(0.02,0.015,0)*CFrame.Angles(0,math.rad(0.3),0),walkoffset)
  150. end
  151. if iswalk == 5 then
  152. breath = breath:lerp(breath*CFrame.new(0.015,0.01,0)*CFrame.Angles(0,math.rad(0.2),0),walkoffset)
  153. end
  154. if iswalk == 6 then
  155. breath = breath:lerp(breath*CFrame.new(0.01,0.005,0)*CFrame.Angles(0,math.rad(0.1),0),walkoffset)
  156. end
  157.  
  158.  
  159. if iswalk == 7 then
  160. breath = breath:lerp(breath*CFrame.new(0,0,0)*CFrame.Angles(0,math.rad(0),0),walkoffset)
  161. end
  162. if iswalk == 8 then
  163. breath = breath:lerp(breath*CFrame.new(-0.01,0.005,0)*CFrame.Angles(0,math.rad(-0.1),0),walkoffset)
  164. end
  165. if iswalk == 9 then
  166. breath = breath:lerp(breath*CFrame.new(-0.015,0.01,0)*CFrame.Angles(0,math.rad(-0.2),0),walkoffset)
  167. end
  168. if iswalk == 10 then
  169. breath = breath:lerp(breath*CFrame.new(-0.02,0.015,0)*CFrame.Angles(0,math.rad(-0.3),0),walkoffset)
  170. end
  171. if iswalk == 11 then
  172. breath = breath:lerp(breath*CFrame.new(-0.015,0.01,0)*CFrame.Angles(0,math.rad(-0.2),0),walkoffset)
  173. end
  174. if iswalk == 12 then
  175. breath = breath:lerp(breath*CFrame.new(-0.01,0.005,0)*CFrame.Angles(0,math.rad(-0.1),0),walkoffset)
  176. end
  177. end
  178. end
  179.  
  180. runs.RenderStepped:Connect(function()
  181. camera.CFrame = camera.CFrame*CFrame.new(0,-0.1,3)
  182. positionSettings()
  183. end)
  184.  
  185.  
  186.  
  187. while true do
  188. runs.RenderStepped:Wait()
  189. if not walking then
  190. wait(runs.RenderStepped:Wait()*stepwait)
  191. isbreath = isbreath + 1
  192. if isbreath == 9 then
  193. isbreath = 1
  194. end
  195. else
  196. wait(runs.RenderStepped:Wait()*stepwalk)
  197. iswalk = iswalk + 1
  198. if iswalk == 12 then
  199. iswalk = 1
  200. end
  201. end
  202.  
  203. end
  204. runs:BindToRenderStep("smoof",Enum.RenderPriority.Camera.Value == Enum.RenderPriority.Camera.Value+2 ,positionSettings() )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement