Advertisement
Mdbook

Untitled

Mar 6th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. --[[ By Sugerkid123]]--
  2.  
  3. --//Main
  4. local Player = game.Players.LocalPlayer
  5. local Character = Player.Character
  6. local Mouse = Player:GetMouse()
  7. local Animate = Character:FindFirstChild("Animate")
  8. if Animate then Animate:Destroy() end
  9. local ShirtId = "rbxassetid://"
  10. local PantsId = "rbxassetid://"
  11.  
  12. local State = "Idle"
  13.  
  14. local Sitting = false
  15. local Animations = false
  16. local Sprinting = false
  17.  
  18. local rad = math.rad
  19. local sin = math.sin
  20. local cos = math.cos
  21.  
  22. --//Parts
  23. local RA = Character["Right Arm"]
  24. local LA = Character["Left Arm"]
  25. local RL = Character["Right Leg"]
  26. local LL = Character["Left Leg"]
  27. local T = Character["Torso"]
  28. local H = Character["Head"]
  29. local HRP = Character["HumanoidRootPart"]
  30. local Humanoid = Character["Humanoid"]
  31.  
  32. local Broom = Instance.new('Part',Character)
  33. Broom.Size = Vector3.new(1, 1.2, 9)
  34. local BroomMesh = Instance.new('SpecialMesh',Broom)
  35. BroomMesh.MeshId = "http://www.roblox.com/asset/?id=36365830"
  36. BroomMesh.TextureId = "http://www.roblox.com/asset/?id=36365793"
  37. BroomMesh.Scale = Vector3.new(1,1,1.2)
  38. Broom.CanCollide = false
  39.  
  40. Humanoid.JumpPower = 0
  41.  
  42. for i,v in pairs(Character:GetChildren()) do
  43. if v.ClassName == "Accessory" or v.ClassName == "Hat" then v:Destroy() end
  44. if v.ClassName == "Shirt" or v.ClassName == "Pants" then v:Destroy() end
  45. if v.ClassName == "BodyColors" then v:Destroy() end
  46. end
  47.  
  48. local Shirt = Instance.new('Shirt',Character)
  49. local Pants = Instance.new('Pants',Character)
  50. Shirt.ShirtTemplate = ShirtId
  51. Pants.PantsTemplate = PantsId
  52.  
  53. if H:FindFirstChild('face') then
  54. H.face.Texture = "rbxassetid://8329438"
  55. end
  56.  
  57. --//Funcs
  58. function Weld(x,y)
  59. local w = Instance.new("Weld")
  60. w.Part0 = x
  61. w.Part1 = y
  62. w.Name = tostring(y.Name).."_Weld"
  63. w.Parent = x
  64. return w
  65. end
  66.  
  67. function Clerp(start,destination,increment)
  68. local function slerp(a,b,c)return (1-c)*a+(c*b)end
  69. local c1 = {start.X,start.Y,start.Z,start:toEulerAnglesXYZ()}
  70. local c2 = {destination.X,destination.Y,destination.Z,destination:toEulerAnglesXYZ()}
  71. for i,v in pairs(c1)do c1[i] = slerp(v,c2[i],increment)end
  72. return CFrame.new(c1[1],c1[2],c1[3])*CFrame.Angles(c1[4],c1[5],c1[6])
  73. end
  74.  
  75. function CheckState()
  76. local XZMagnitude = Vector3.new(HRP.Velocity.X, 0, HRP.Velocity.Z).Magnitude
  77. local YMagnitude = Vector3.new(0, HRP.Velocity.Y, 0).Magnitude
  78. if XZMagnitude > 2 then State = "Walking" elseif XZMagnitude < 2 then State = "Idle" end
  79. if YMagnitude > 1.5 then State = "Jumping" end
  80. return State
  81. end
  82.  
  83. --//Welds
  84. local TW = Weld(HRP,T)
  85. local RAW = Weld(T,RA)
  86. local LAW = Weld(T,LA)
  87. local RLW = Weld(T,RL)
  88. local LLW = Weld(T,LL)
  89. local HW = Weld(T,H)
  90. local BW = Weld(T,Broom)
  91.  
  92. Humanoid.WalkSpeed = 30
  93.  
  94.  
  95. function cap(n,x,f)
  96. if f==nil then f=false end
  97. if f then if x>n then x=n end else if x<n then x = n end end
  98. return x
  99. end
  100. --//Animate!
  101.  
  102. while true do
  103. game:GetService('RunService').RenderStepped:wait()
  104. local S = CheckState()
  105.  
  106. local lefth = (T.CFrame*CFrame.new(-.5,-2,0))
  107. local righth = (T.CFrame*CFrame.new(.5,-2,0))
  108. local speed = Vector3.new(T.Velocity.X,0,T.Velocity.Z)
  109. local TiltOnAxis = (HRP.CFrame-HRP.CFrame.p):inverse()*speed/100
  110. local AnglePR = (righth-righth.p):inverse()*speed/100
  111. local AnglePL = (lefth-lefth.p):inverse()*speed/100
  112. local AngleThetaR = (righth-righth.p):vectorToObjectSpace(speed/100)
  113. local AngleThetaL = (lefth-lefth.p):vectorToObjectSpace(speed/100)
  114.  
  115. if S == "Idle" and not Animations then
  116. BW.C0 = Clerp(BW.C0, CFrame.new(0,-.8,-1)*CFrame.Angles(rad(20),rad(180),0), .1)
  117. TW.C0 = Clerp(TW.C0, CFrame.new(0,sin(tick())/20,-.3)*CFrame.Angles(-rad(20),0,0),.1)
  118. HW.C0 = Clerp(HW.C0, CFrame.new(0,1.5,0)*CFrame.Angles(rad(20),0,0), .1)
  119. RAW.C0 = Clerp(RAW.C0, CFrame.new(.7,-.1,-.8)*CFrame.Angles(rad(60),0,-rad(20)), .1)
  120. LAW.C0 = Clerp(LAW.C0, CFrame.new(-.7,-.1,-.8)*CFrame.Angles(rad(60),0,rad(20)), .1)
  121. RLW.C0 = Clerp(RLW.C0, CFrame.new(.5,-1.5,-.4+rad(20))*CFrame.Angles(-rad(20),0,0),.1)
  122. LLW.C0 = Clerp(LLW.C0, CFrame.new(-.5,-1.5,-.4+rad(30))*CFrame.Angles(-rad(30),0,0),.1)
  123. elseif S == "Walking" and not Animations then
  124.  
  125. local RV = sin(HRP.RotVelocity.Y/15)*2
  126.  
  127. BW.C0 = Clerp(BW.C0, CFrame.new(0,-.8,-1)*CFrame.Angles(rad(20),rad(180),0), .1)
  128. TW.C0 = Clerp(TW.C0, CFrame.new(0,0,-.3)*CFrame.Angles(-rad(20)+sin(AnglePR.Z)*2,0,-sin(AnglePR.X)+RV),.1)
  129. end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement