Advertisement
HenloMyDude

sonic the hedgehog (classic)

Dec 20th, 2019
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.85 KB | None | 0 0
  1.  
  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,Mouse,mouse,UserInputService,ContextActionService = owner
  4. local RealPlayer = Player
  5. do print("classic sonic loaded, by youngmacka123. dont steal and claim as urs pls")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
  6.  
  7. plr = owner
  8. char = plr.Character
  9. ra = char["Right Arm"]
  10. la = char["Left Arm"]
  11. hed = char.Head
  12. root = char.HumanoidRootPart
  13. hum = char.Humanoid
  14. dancin = false
  15.  
  16. clerp = function(toclerp, cf, number)
  17. local joint = toclerp
  18. joint.C0 = joint.C0:Lerp(cf, number)
  19. end
  20.  
  21. clerp2 = function(toclerp, cf)
  22. local joint = toclerp
  23. joint.C0 = cf
  24. end
  25.  
  26. clerp3 = function(toclerp, cf, number)
  27. local joint = toclerp
  28. joint.C1 = joint.C1:Lerp(cf, number)
  29. end
  30.  
  31. Swait,swait = function(number)
  32. if number == 0 or number == nil then
  33. game:GetService("RunService").Heartbeat:Wait()
  34. else
  35. for i = 1,number do
  36. game:GetService("RunService").Heartbeat:Wait()
  37. end
  38. end
  39. end
  40.  
  41. ezweld = function(p, a, b, cf)
  42. local weld = Instance.new("Weld",p)
  43. weld.Part0 = a
  44. weld.Part1 = b
  45. weld.C0 = cf
  46. return weld
  47. end
  48.  
  49. NewSound = function(p, id, pit, vol, loop)
  50. local Sound = Instance.new("Sound",p)
  51. Sound.Pitch = pit
  52. Sound.Volume = vol
  53. Sound.SoundId = "rbxassetid://" ..id
  54. Sound.Looped = loop
  55. Sound:Play()
  56. return Sound
  57. end
  58.  
  59. IT = Instance.new
  60. Rad = math.rad
  61. Cos = math.cos
  62. Sin = math.sin
  63. BrickC = BrickColor.new
  64. C3 = Color3.new
  65. VT = Vector3.new
  66.  
  67. anim = "Idle"
  68. attack = false
  69. local RS = char.Torso["Right Shoulder"]
  70. local LS = char.Torso["Left Shoulder"]
  71. local RH = char.Torso["Right Hip"]
  72. local LH = char.Torso["Left Hip"]
  73. local neck = char.Torso["Neck"]
  74. local root = char.HumanoidRootPart
  75. local rootj = root.RootJoint
  76. local sine = 0
  77. local RSnor = RS.C0
  78. local LSnor = LS.C0
  79. local RHnor = RH.C0
  80. local LHnor = LH.C0
  81. local RSnor2 = RS.C1
  82. local LSnor2 = LS.C1
  83. local RHnor2 = RH.C1
  84. local LHnor2 = LH.C1
  85. local rootjnor = rootj.C0
  86. local necknor = neck.C0
  87. local tors = char.Torso
  88. hum.Animator:remove()
  89. mouse = plr:GetMouse()
  90. hold = false
  91. Debris = game:GetService("Debris")
  92.  
  93. sped = 16
  94. keyhold = false
  95. spino = 0
  96. hito = true
  97.  
  98. function RayCast(Position, Direction, Range, Ignore)
  99. return game:service("Workspace"):FindPartOnRay(Ray.new(Position, Direction.unit * (Range or 999.999)), Ignore)
  100. end
  101.  
  102. zone = NewSound(hed, 297699305, 1, 6, true)
  103.  
  104. local spin = NewSound(root, 163619849, 1, 6, false)
  105. spin.Playing = false
  106.  
  107. function dash()
  108. attack = true
  109. keyhold = true
  110. local bv = Instance.new("BodyVelocity",root)
  111. bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  112. bv.Velocity = root.CFrame.lookVector * 0
  113. local ea = 7
  114. repeat
  115. Swait()
  116. if not char:FindFirstChild("yus") then
  117. spin.Pitch = spin.Pitch + 0.05
  118. spin:Play()
  119. local yus = Instance.new("NumberValue", char)
  120. yus.Name = "yus"
  121. Debris:AddItem(yus, 0.15)
  122. end
  123. ea = ea + 1
  124. rootj.C0 = rootjnor * CFrame.Angles(spino, 0, 0)
  125. clerp(neck, necknor * CFrame.Angles(Rad(45), 0, 0), 0.3)
  126. clerp(RH, RHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(0.5, 0.35, 0), 0.3)
  127. clerp(LH, LHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(-0.5, 0.35, 0), 0.3)
  128. clerp(RS, RSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(45)), 0.3)
  129. clerp(LS, LSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(-45)), 0.3)
  130. until keyhold == false
  131. spin.Pitch = 1
  132. spin.Playing = false
  133. local wee = NewSound(hed, 500223047, 1, 6, false)
  134. Debris:AddItem(wee, 2)
  135. Debris:AddItem(bv, ea)
  136. bv.Velocity = root.CFrame.lookVector * (ea + 150)
  137. local hitman = tors.Touched:connect(function(hit)
  138. local dud = hit.Parent
  139. if hit.Parent:IsA("Accessory") or hit.Parent:IsA("Hat") then
  140. dud = hit.Parent.Parent
  141. end
  142. if dud ~= char and hito then
  143. for i,v in pairs (dud:children()) do
  144. if v:IsA("Humanoid") and v.Health ~= 0 then
  145. v.Health = 0
  146. v.MaxHealth = 0
  147. NewSound(hed, 130792936, 1, 10, false)
  148. end
  149. end
  150. end
  151. end)
  152. if ea < 45 then
  153. for i = 1,ea do
  154. Swait()
  155. bv.MaxForce = Vector3.new(math.huge, 0, math.huge)
  156. rootj.C0 = rootjnor * CFrame.Angles(spino, 0, 0)
  157. clerp(neck, necknor * CFrame.Angles(Rad(45), 0, 0), 0.3)
  158. clerp(RH, RHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(0.5, 0.35, 0), 0.3)
  159. clerp(LH, LHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(-0.5, 0.35, 0), 0.3)
  160. clerp(RS, RSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(45)), 0.3)
  161. clerp(LS, LSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(-45)), 0.3)
  162. end
  163. elseif ea > 44 then
  164. for i = 1,45 do
  165. Swait()
  166. bv.MaxForce = Vector3.new(math.huge, 0, math.huge)
  167. rootj.C0 = rootjnor * CFrame.Angles(spino, 0, 0)
  168. clerp(neck, necknor * CFrame.Angles(Rad(45), 0, 0), 0.3)
  169. clerp(RH, RHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(0.5, 0.35, 0), 0.3)
  170. clerp(LH, LHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(-0.5, 0.35, 0), 0.3)
  171. clerp(RS, RSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(45)), 0.3)
  172. clerp(LS, LSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(-45)), 0.3)
  173. end
  174. end
  175. hitman:disconnect()
  176. bv:remove()
  177. keyhold = false
  178. attack = false
  179. end
  180.  
  181. mouse.KeyDown:connect(function(key)
  182. if key == "z" then
  183. dash()
  184. end
  185. end)
  186.  
  187. songid = 0
  188.  
  189. mouse.KeyUp:connect(function(key)
  190. if key == "z" then
  191. keyhold = false
  192. end
  193. if key == "p" then
  194. if hito then
  195. hito = false
  196. else
  197. hito = true
  198. end
  199. end
  200. if key == "m" then
  201. if zone.Playing == true then
  202. zone.Playing = false
  203. else
  204. zone.Playing = true
  205. end
  206. end
  207. if key == "l" then
  208. if songid == 0 then
  209. songid = 1
  210. zone.SoundId = "rbxassetid://142286444"
  211. elseif songid == 1 then
  212. songid = 2
  213. zone.SoundId = "rbxassetid://183866857"
  214. elseif songid == 2 then
  215. songid = 0
  216. zone.SoundId = "rbxassetid://297699305"
  217. end
  218. end
  219. end)
  220.  
  221. tors.Touched:connect(function(hit)
  222. local dud = hit.Parent
  223. hitfloor = RayCast(root.Position, (CFrame.new(root.Position, root.Position + Vector3.new(0, -1, 0))).lookVector, tors.Size.y+2+hum.HipHeight, char)
  224. if hit.Parent:IsA("Accessory") or hit.Parent:IsA("Hat") then
  225. dud = hit.Parent.Parent
  226. end
  227. if dud ~= char and hitfloor == nil and hito == true then
  228. for i,v in pairs (dud:children()) do
  229. if v:IsA("Humanoid") and v.Health ~= 0 then
  230. v.Health = 0
  231. v.MaxHealth = 0
  232. NewSound(hed, 130792936, 1, 10, false)
  233. end
  234. end
  235. end
  236. if hit.Size == Vector3.new(5, 1, 5) then
  237. local bv = Instance.new("BodyVelocity",root)
  238. bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  239. bv.Velocity = Vector3.new(0, 120, 0)
  240. Debris:AddItem(bv, 0.15)
  241. attack = true
  242. for i = 1,45 do
  243. Swait()
  244. clerp(rootj, rootjnor * CFrame.new(0, 0, 0.025 * Cos(sine / 24)) * CFrame.Angles(0, 0, spino / 2), 0.3)
  245. clerp(neck, necknor * CFrame.Angles(Rad(65), 0, Rad(0)), 0.3)
  246. clerp(RH, RHnor * CFrame.Angles(Rad(-3), Rad(0), Rad(0)) * CFrame.new(0, -0.025 * Cos(sine / 24), 0), 0.3)
  247. clerp(LH, LHnor * CFrame.Angles(Rad(-3), Rad(0), Rad(0)) * CFrame.new(0, -0.025 * Cos(sine / 24), 0), 0.3)
  248. clerp(RS, RSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(-25), Rad(0), Rad(0)), 0.3)
  249. clerp(LS, LSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(-25), Rad(0), Rad(0)), 0.3)
  250. end
  251. attack = false
  252. end
  253. end)
  254.  
  255. hum.BreakJointsOnDeath = false
  256. hum.Died:connect(function()
  257. attack = true
  258. NewSound(hed, 571879674, 1, 10, false)
  259. local bv = Instance.new("BodyVelocity",root)
  260. bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  261. bv.Velocity = Vector3.new(0, 75, 0)
  262. Debris:AddItem(bv, 0.1)
  263. for i = 1,35 do
  264. Swait()
  265. clerp(rootj, rootjnor * CFrame.new(0, 0, 0.025 * Cos(sine / 24)) * CFrame.Angles(0, 0, Rad(0)), 0.3)
  266. clerp(neck, necknor * CFrame.Angles(0, 0, Rad(0)), 0.3)
  267. clerp(RH, RHnor * CFrame.Angles(Rad(-25), Rad(0), Rad(0)) * CFrame.new(0, -0.025 * Cos(sine / 24), 0), 0.3)
  268. clerp(LH, LHnor * CFrame.Angles(Rad(-25), Rad(0), Rad(0)) * CFrame.new(0, -0.025 * Cos(sine / 24), 0), 0.3)
  269. clerp(RS, RSnor * CFrame.new(0, 0, 0.75) * CFrame.Angles(Rad(-170), Rad(0), Rad(0)), 0.3)
  270. clerp(LS, LSnor * CFrame.new(0, 0, 0.75) * CFrame.Angles(Rad(-170), Rad(0), Rad(0)), 0.3)
  271. end
  272. for i = 1,70 do
  273. Swait()
  274. end
  275. --char.Parent = nil
  276. end)
  277.  
  278. dust = Instance.new("ParticleEmitter", nil)
  279.  
  280. while true do
  281. Swait()
  282. sine = sine + 1
  283. spino = spino + Rad(45)
  284. hum.JumpPower = 70
  285. hum.WalkSpeed = sped
  286. local TiltVelocity = CFrame.new(root.CFrame:vectorToObjectSpace(root.Velocity/1.6))
  287. local TORSOVELOCITY = (root.Velocity * VT(1, 0, 1)).magnitude
  288. local WALKSPEEDVALUE = 8 / (sped / 16)
  289. torsverticalvel = root.Velocity.y
  290. hitfloor = RayCast(root.Position, (CFrame.new(root.Position, root.Position + Vector3.new(0, -1, 0))).lookVector, tors.Size.y+2+hum.HipHeight, char)
  291. if TORSOVELOCITY < 1 and hitfloor ~= nil then
  292. anim = "Idle"
  293. if attack == false then
  294. sped = 5
  295. dust.Enabled = false
  296. clerp(rootj, rootjnor * CFrame.new(0, 0, 0.025 * Cos(sine / 24)) * CFrame.Angles(0, 0, Rad(-45)), 0.3)
  297. clerp(neck, necknor * CFrame.Angles(0, 0, Rad(45)), 0.3)
  298. clerp(RH, RHnor * CFrame.Angles(0, Rad(15), Rad(-15)) * CFrame.new(0, -0.025 * Cos(sine / 24), 0), 0.3)
  299. clerp(LH, LHnor * CFrame.Angles(0, Rad(15), 0) * CFrame.new(0, -0.025 * Cos(sine / 24), 0), 0.3)
  300. clerp(RS, RSnor * CFrame.new(-0.1, -0.25 - 0.025 * Cos(sine / 12), 0) * CFrame.Angles(Rad(0), Rad(0), Rad(65)), 0.3)
  301. clerp(LS, LSnor * CFrame.new(-0.1, -0.25 - 0.025 * Cos(sine / 12), 0) * CFrame.Angles(Rad(0), Rad(0), Rad(-65)), 0.3)
  302. end
  303. elseif TORSOVELOCITY > 1 and hitfloor ~= nil then
  304. anim = "Walk"
  305. if attack == false then
  306. if sped ~= 65 then
  307. sped = sped + 0.5
  308. end
  309. dust.Enabled = false
  310. if sped < 65 then
  311. local heeh = 6
  312. clerp(rootj, rootjnor * CFrame.new(0, 0, 0.05 * Cos(sine / (15)) * 0.1 - 0.1 * Cos(sine / (heeh / 2.5))) * CFrame.Angles(Rad(15 + 2 * Cos((heeh / 2))) - Rad(root.Velocity.y) * 1.25, -root.RotVelocity.y / 35, Rad(0 + 7 * Cos(sine / (heeh / 2)))), 0.3)
  313. clerp(neck, necknor * CFrame.Angles(Rad(-15 - 2 * Cos((heeh / 2))), 0, Rad(0 - 7 * Cos(sine / (heeh / 2)))), 0.3)
  314. clerp(RH, RHnor * CFrame.new(0.4 * Cos(sine / (heeh / 2.5)), -0.1 + 0.2 * Cos(sine / (heeh / 2.5)), 0) * CFrame.Angles(0, 0, Rad(90 * Cos(sine / (heeh / 1.5)))), 0.3)
  315. clerp(LH, LHnor * CFrame.new(0.4 * Cos(sine / (heeh / 2.5)), -0.1 + 0.2 * Cos(sine / (heeh / 2.5)), 0) * CFrame.Angles(0, 0, Rad(90 * Cos(sine / (heeh / 1.5)))), 0.3)
  316. clerp(RS, RSnor * CFrame.Angles(0, 0, Rad(90 * Cos(sine / (heeh / 1.5)))), 0.3)
  317. clerp(LS, LSnor * CFrame.Angles(0, 0, Rad(90 * Cos(sine / (heeh / 1.5)))), 0.3)
  318. elseif sped > 64 then
  319. local heeh = 2
  320. clerp(rootj, rootjnor * CFrame.new(0, 0, 0.05 * Cos(sine / (15)) * 0.025 - 0.025 * Cos(sine / (heeh / 2))) * CFrame.Angles(Rad(7 + 1 * Cos(sine / (heeh / 1.5))) - Rad(root.Velocity.y) * 1.25, -root.RotVelocity.y / 35, Rad(0 + 0.5 * Cos(sine / (heeh / 1.5)))), 0.3)
  321. clerp(neck, necknor * CFrame.Angles(Rad(-7 - 1 * Cos((WALKSPEEDVALUE / 2))), 0, Rad(0 - 0.5 * Cos(sine / (WALKSPEEDVALUE / 2)))), 0.3)
  322. clerp(RH, RHnor * CFrame.new(0.4 * Cos(sine / (heeh / 2)), -0.1 + 0.2 * Cos(sine / (heeh / 2)), 0) * CFrame.Angles(0, 0, Rad(180 * Cos(sine / heeh))), 0.3)
  323. clerp(LH, LHnor * CFrame.new(0.4 * Cos(sine / (heeh / 2)), -0.1 + 0.2 * Cos(sine / (heeh / 2)), 0) * CFrame.Angles(0, 0, Rad(180 * Cos(sine / heeh))), 0.3)
  324. clerp(RS, RSnor * CFrame.new(-0.1, -0.25 - 0 * Cos(sine / 12), 0) * CFrame.Angles(Rad(0), Rad(0), Rad(65)), 0.3)
  325. clerp(LS, LSnor * CFrame.new(-0.1, -0.25 - 0 * Cos(sine / 12), 0) * CFrame.Angles(Rad(0), Rad(0), Rad(-65)), 0.3)
  326. end
  327. end
  328. elseif torsverticalvel > 0.5 and hitfloor == nil then
  329. anim = "Jump"
  330. if not hed:FindFirstChild("jump") then
  331. local jump = Instance.new("Sound", hed)
  332. jump.Name = "jump"
  333. jump.SoundId = "rbxassetid://130782425"
  334. jump.Volume = 1
  335. jump:Play()
  336. Debris:AddItem(jump, 0.5)
  337. end
  338. if attack == false then
  339. sped = sped
  340. dust.Enabled = false
  341. rootj.C0 = rootjnor * CFrame.Angles(spino, 0, 0)
  342. clerp(neck, necknor * CFrame.Angles(Rad(45), 0, 0), 0.3)
  343. clerp(RH, RHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(0.5, 0.35, 0), 0.3)
  344. clerp(LH, LHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(-0.5, 0.35, 0), 0.3)
  345. clerp(RS, RSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(45)), 0.3)
  346. clerp(LS, LSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(-45)), 0.3)
  347. end
  348. elseif torsverticalvel < 0.5 and hitfloor == nil then
  349. anim = "Fall"
  350. if attack == false then
  351. sped = sped
  352. dust.Enabled = false
  353. rootj.C0 = rootjnor * CFrame.Angles(spino, 0, 0)
  354. clerp(neck, necknor * CFrame.Angles(Rad(45), 0, 0), 0.3)
  355. clerp(RH, RHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(0.5, 0.35, 0), 0.3)
  356. clerp(LH, LHnor * CFrame.Angles(Rad(0), Rad(0), Rad(0)) * CFrame.new(-0.5, 0.35, 0), 0.3)
  357. clerp(RS, RSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(45)), 0.3)
  358. clerp(LS, LSnor * CFrame.new(0, 0, 0) * CFrame.Angles(Rad(25), 0, Rad(-45)), 0.3)
  359. end
  360. end
  361. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement