codemen

Cuphead's Lobber gun script [roblox]

Nov 13th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.54 KB | None | 0 0
  1. local plr = game:service'Players'.LocalPlayer
  2. local chr = plr.Character
  3. local hum = chr.Humanoid
  4. local rarm = chr["Right Arm"]
  5. local larm= chr["Left Arm"]
  6. local rleg= chr["Right Leg"]
  7. local lleg = chr["Left Leg"]
  8. local root = chr.HumanoidRootPart
  9. local tors = chr.Torso
  10. local head = chr.Head
  11. local RunS = game:GetService("RunService")
  12. local mouse = plr:GetMouse()
  13. local RenderS = RunS.RenderStepped
  14. local t = tick()
  15. local defAnim = true
  16. local action = ''
  17. local CF = {N=CFrame.new,A=CFrame.Angles,fEA=CFrame.fromEulerAnglesXYZ}
  18. local V3 = {N=Vector3.new}
  19. local M = {C=math.cos,R=math.rad,S=math.sin,P=math.pi,RNG=math.random,MRS=math.randomseed,H=math.huge}
  20. local Effects,Sounds = {},{};
  21.  
  22.  
  23. Sounds['Wet'] = {Id=256738023,Loop=false,Pitch=1}
  24. Sounds['Swoosh1'] = {Id=320557353,Loop=false,Pitch=1}
  25. Sounds['Swoosh2'] = {Id=320557382,Loop=false,Pitch=1}
  26. Sounds['Swoosh3'] = {Id=320557413,Loop=false,Pitch=1}
  27. Sounds['Swoosh4'] = {Id=320557453,Loop=false,Pitch=1}
  28. Sounds['Swoosh5'] = {Id=320557487,Loop=false,Pitch=1}
  29. Sounds['Swoosh6'] = {Id=320557537,Loop=false,Pitch=1}
  30. Sounds['Swoosh7'] = {Id=320557563,Loop=false,Pitch=1}
  31. Sounds['Swoosh8'] = {Id=320557518,Loop=false,Pitch=1}
  32. Sounds['ShrekRemix'] = {Id=163306929,Loop=true,Pitch=1,Volume = 4}
  33. Sounds['CreoDimension'] = {Id=927529620,Loop=true,Pitch=1,Volume=4}
  34. Sounds['BlackBlizzard'] = {Id=657626121,Loop=true,Pitch=1,Volume=4}
  35. Sounds['ColbreakzFantasy'] = {Id=876981900,Loop=true,Pitch=1,Volume=4}
  36. Sounds['NeflCrystals'] = {Id=340106355,Loop=true,Pitch=1,Volume=4}
  37. Sounds['EvilMortyRemix'] = {Id=1057401232,Loop=true,Pitch=1,Volume=10}
  38.  
  39. local NewInstance = function(instance,parent,properties)
  40. local inst = Instance.new(instance,parent)
  41. if properties then
  42. for i,v in next, properties do
  43. pcall(function() inst[i] = v end)
  44. end
  45. end
  46. return inst;
  47. end
  48. local sndFromData = function(data,parent)
  49. if typeof(data) == 'table' then
  50. local snd = NewInstance("Sound",parent or chr,{SoundId = "rbxassetid://"..data.Id,Looped=data.Loop or false,Pitch = data.Pitch or 1,Volume = data.Volume or 1})
  51. return snd;
  52. else
  53. return error('Argument passed into sndFromData must be a table!',1)
  54. end
  55. end
  56.  
  57. New = function(Object, Parent, Name, Data)
  58. local Object = Instance.new(Object)
  59. for Index, Value in pairs(Data or {}) do
  60. Object[Index] = Value
  61. end
  62. Object.Parent = Parent
  63. Object.Name = Name
  64. return Object
  65. end
  66.  
  67. -- Build
  68. fongr = New("Part",larm,"fongr",{BrickColor = (chr:FindFirstChildOfClass"Body Colors" and chr:FindFirstChildOfClass"Body Colors".LeftArmColor or larm.BrickColor),Material = Enum.Material.SmoothPlastic,FormFactor = Enum.FormFactor.Symmetric,Size = Vector3.new(0.193568379, 1.20012438, 0.193568379),CFrame = CFrame.new(12.9260693, 1.73919964, -21.1709423, -1, 0, 0, 0, 1, 0, 0, 0, -1),CanCollide = false,BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(1, 0.8, 0.6),})
  69. mot = New("Motor",fongr,"mot",{Part0 = fongr,Part1 = larm,C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),C1 = CFrame.new(-0.301872253, -1.24136782, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),})
  70. fongr = New("Part",larm,"fongr",{BrickColor = (chr:FindFirstChildOfClass"Body Colors" and chr:FindFirstChildOfClass"Body Colors".LeftArmColor or larm.BrickColor),Material = Enum.Material.SmoothPlastic,FormFactor = Enum.FormFactor.Symmetric,Size = Vector3.new(0.193568379, 0.688505769, 0.193568379),CFrame = CFrame.new(13.2772827, 2.0387857, -21.1709423, 0.0177989937, -0.99984163, 0, -0.99984163, -0.0177989937, 0, -0, 0, -1),CanCollide = false,BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(1, 0.8, 0.6),})
  71. mot = New("Motor",fongr,"mot",{Part0 = fongr,Part1 = larm,C0 = CFrame.new(0, 0, 0, 0.0177989937, -0.99984163, 0, -0.99984163, -0.0177989937, 0, 0, 0, -1),C1 = CFrame.new(-0.653085709, -0.941781759, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),})
  72. fongr = New("Part",larm,"fongr",{BrickColor = (chr:FindFirstChildOfClass"Body Colors" and chr:FindFirstChildOfClass"Body Colors".LeftArmColor or larm.BrickColor),Material = Enum.Material.SmoothPlastic,FormFactor = Enum.FormFactor.Symmetric,Size = Vector3.new(0.193568379, 1.20012438, 0.193568379),CFrame = CFrame.new(12.7063389, 1.73919964, -21.1709423, -1, 0, 0, 0, 1, 0, 0, 0, -1),CanCollide = false,BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(1, 0.8, 0.6),})
  73. mot = New("Motor",fongr,"mot",{Part0 = fongr,Part1 = larm,C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),C1 = CFrame.new(-0.0821418762, -1.24136782, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),})
  74.  
  75. -- Joints
  76. local LS = NewInstance('Weld',tors,{Part0=tors,Part1=larm,C0 = CF.N(-1.5,0.5,0),C1 = CF.N(0,.5,0)})
  77. local RS = NewInstance('Weld',tors,{Part0=tors,Part1=rarm,C0 = CF.N(1.5,0.5,0),C1 = CF.N(0,.5,0)})
  78. local NK = NewInstance('Weld',tors,{Part0=tors,Part1=head,C0 = CF.N(0,1.5,0)})
  79. local LH = NewInstance('Weld',tors,{Part0=tors,Part1=lleg,C0 = CF.N(-.5,-1,0),C1 = CF.N(0,1,0)})
  80. local RH = NewInstance('Weld',tors,{Part0=tors,Part1=rleg,C0 = CF.N(.5,-1,0),C1 = CF.N(0,1,0)})
  81. local RJ = NewInstance('Weld',tors,{Part0=tors,Part1=root})
  82.  
  83.  
  84. -- Default C0s
  85. local LSD=LS.C0
  86. local RSD=RS.C0
  87. local HD=NK.C0
  88. local TD=RJ.C0
  89. local LHD=LH.C0
  90. local RHD=RH.C0
  91. local holding = false
  92. function shot()
  93. if(holding)then
  94. local bullet = Instance.new('Part',chr)
  95. bullet.CFrame = CF.N(larm.CFrame.p,mouse.Hit.p)
  96. bullet.FormFactor = "Custom"
  97. bullet.Size = Vector3.new(1,1,1)
  98. bullet.CanCollide = false
  99. bullet.Transparency = 0.25
  100. bullet.Shape = 'Ball'
  101. bullet.Color = Color3.fromRGB(200, 76, 200)
  102. local bodyVelocity = Instance.new('BodyVelocity',bullet)
  103. bodyVelocity.velocity = (mouse.Hit.p - larm.CFrame.p).unit * 75
  104. delay(.2, function()
  105. bodyVelocity:destroy()
  106. end)
  107. bullet.Touched:connect(function(o)
  108. if o.Parent ~= chr and o.Parent.Parent ~= chr then
  109. local h = o.Parent:FindFirstChildOfClass'Humanoid'
  110. if h then
  111. h.Health = h.Health - h.MaxHealth/4
  112. end
  113. bullet:destroy()
  114. end
  115. end)
  116. end
  117. end
  118.  
  119. mouse.Button1Down:connect(function()
  120. defAnim = false;
  121. holding = true;
  122. repeat wait(.3) action = 'Attackie1' shot() wait(.15) action = 'Attackie2' until holding == false
  123. defAnim = true;
  124. end)
  125. mouse.Button1Up:connect(function()
  126. holding = false;
  127. end)
  128. local c = 0.5;
  129.  
  130. --hum.AutoRotate = false;
  131. local stance = 'Idle'
  132. RenderS:connect(function()
  133. t = t + c
  134. --mouse.TargetFilter = workspace;
  135. --tors.CFrame = CFrame.new(tors.Position, Vector3.new(mouse.Hit.p.X, 0, mouse.Hit.p.Z))
  136. if math.abs(root.Velocity.x) > 2 or math.abs(root.Velocity.z) > 2 and hum:GetState() ~= Enum.HumanoidStateType.Freefall then
  137. stance = "Walk"
  138. elseif math.abs(root.Velocity.x) < 2 or math.abs(root.Velocity.z) < 2 then
  139. stance = "Idle"
  140. end
  141. if defAnim then
  142. if(stance == "Walk")then
  143. RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
  144. --RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
  145. NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
  146. RH.C0 = RH.C0:lerp(CF.N(.5,-1+.45*M.C(t/12)/4,.05+-M.S(t/12)/4)*CF.A(M.R(-12)+M.S(t/12)/2.3,0,0),.3)
  147. LH.C0 = LH.C0:lerp(CF.N(-.5,-1-.45*M.C(t/12)/4,.05+M.S(t/12)/4)*CF.A(M.R(-12)+-M.S(t/12)/2.3,0,0),.3)
  148. RS.C0 = RS.C0:lerp(CF.N(1.5,.5,-M.S(t/14)/4)*CF.A(M.S(t/14)/4,0,0),.3)
  149. LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0),0.1)
  150. c = 1
  151. else
  152. LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0),0.1)
  153. RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
  154. LH.C0 = LH.C0:lerp(CFrame.new(-0.440940678, -0.992188036, 0.0145819485, 0.998181283, 0.0590542518, 0.012143841, -0.0602898225, 0.97772485, 0.201056987, -5.22762598e-08, -0.201423571, 0.979505241),0.1)
  155. NK.C0 = NK.C0:lerp(CFrame.new(7.62939999e-06, 1.49997056, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
  156. RH.C0 = RH.C0:lerp(CFrame.new(0.4349491, -0.970435679, -0.0502791964, 0.99788934, -0.0649418086, 0.000381366728, 0.0649427921, 0.997872889, -0.00586463744, 3.0428501e-07, 0.00587702403, 0.999982953),0.1)
  157. RS.C0 = RS.C0:lerp(CFrame.new(1.44655097, 0.506112933, 0.0941094309, 0.994473815, -0.104665354, -0.00821636897, 0.104987323, 0.991423786, 0.0778287426, -6.72606149e-08, -0.0782612264, 0.996932983),0.1)
  158. c = 0.5
  159. end
  160. else
  161. if(action == "Attackie1")then
  162. if(stance == 'Walk') then
  163. c = 1;
  164. RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
  165. --RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
  166. NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
  167. RH.C0 = RH.C0:lerp(CF.N(.5,-1+.45*M.C(t/12)/4,.05+-M.S(t/12)/4)*CF.A(M.R(-12)+M.S(t/12)/2.3,0,0),.3)
  168. LH.C0 = LH.C0:lerp(CF.N(-.5,-1-.45*M.C(t/12)/4,.05+M.S(t/12)/4)*CF.A(M.R(-12)+-M.S(t/12)/2.3,0,0),.3)
  169. RS.C0 = RS.C0:lerp(CF.N(1.5,.5,-M.S(t/14)/4)*CF.A(M.S(t/14)/4,0,0),.3)
  170. else
  171. c = 0.5;
  172. RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
  173. LH.C0 = LH.C0:lerp(CFrame.new(-0.440940678, -0.992188036, 0.0145819485, 0.998181283, 0.0590542518, 0.012143841, -0.0602898225, 0.97772485, 0.201056987, -5.22762598e-08, -0.201423571, 0.979505241),0.1)
  174. NK.C0 = NK.C0:lerp(CFrame.new(7.62939999e-06, 1.49997056, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
  175. RH.C0 = RH.C0:lerp(CFrame.new(0.4349491, -0.970435679, -0.0502791964, 0.99788934, -0.0649418086, 0.000381366728, 0.0649427921, 0.997872889, -0.00586463744, 3.0428501e-07, 0.00587702403, 0.999982953),0.1)
  176. RS.C0 = RS.C0:lerp(CFrame.new(1.44655097, 0.506112933, 0.0941094309, 0.994473815, -0.104665354, -0.00821636897, 0.104987323, 0.991423786, 0.0778287426, -6.72606149e-08, -0.0782612264, 0.996932983),0.1)
  177. end
  178. LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0)*CF.A(0,0,M.R(-25)),0.1)
  179. elseif(action == "Attackie2")then
  180. if(stance == 'Walk') then
  181. c = 1;
  182. RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
  183. --RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
  184. NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
  185. RH.C0 = RH.C0:lerp(CF.N(.5,-1+.45*M.C(t/12)/4,.05+-M.S(t/12)/4)*CF.A(M.R(-12)+M.S(t/12)/2.3,0,0),.3)
  186. LH.C0 = LH.C0:lerp(CF.N(-.5,-1-.45*M.C(t/12)/4,.05+M.S(t/12)/4)*CF.A(M.R(-12)+-M.S(t/12)/2.3,0,0),.3)
  187. RS.C0 = RS.C0:lerp(CF.N(1.5,.5,-M.S(t/14)/4)*CF.A(M.S(t/14)/4,0,0),.3)
  188. else
  189. c = 0.5;
  190. RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
  191. LH.C0 = LH.C0:lerp(CFrame.new(-0.440940678, -0.992188036, 0.0145819485, 0.998181283, 0.0590542518, 0.012143841, -0.0602898225, 0.97772485, 0.201056987, -5.22762598e-08, -0.201423571, 0.979505241),0.1)
  192. NK.C0 = NK.C0:lerp(CFrame.new(7.62939999e-06, 1.49997056, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
  193. RH.C0 = RH.C0:lerp(CFrame.new(0.4349491, -0.970435679, -0.0502791964, 0.99788934, -0.0649418086, 0.000381366728, 0.0649427921, 0.997872889, -0.00586463744, 3.0428501e-07, 0.00587702403, 0.999982953),0.1)
  194. RS.C0 = RS.C0:lerp(CFrame.new(1.44655097, 0.506112933, 0.0941094309, 0.994473815, -0.104665354, -0.00821636897, 0.104987323, 0.991423786, 0.0778287426, -6.72606149e-08, -0.0782612264, 0.996932983),0.1)
  195. end
  196. LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0)*CF.A(0,M.R(0),0),0.1)
  197.  
  198. end
  199. end
  200. end)
Add Comment
Please, Sign In to add comment