BladefuryDood

Advanced Movement (R15) Part 2

Jul 2nd, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 0 0
  1. --Now do this all again but put it in the StarterScripts set...
  2.  
  3. --Converted with ttyyuu12345's model to script plugin v4
  4. function sandbox(var,func)
  5. local env = getfenv(func)
  6. local newenv = setmetatable({},{
  7. __index = function(self,k)
  8. if k=="script" then
  9. return var
  10. else
  11. return env[k]
  12. end
  13. end,
  14. })
  15. setfenv(func,newenv)
  16. return func
  17. end
  18. cors = {}
  19. mas = Instance.new("Model",game:GetService("Lighting"))
  20. LocalScript0 = Instance.new("LocalScript")
  21. Animation1 = Instance.new("Animation")
  22. ParticleEmitter2 = Instance.new("ParticleEmitter")
  23. Animation3 = Instance.new("Animation")
  24. LocalScript0.Name = "MultipleJump"
  25. LocalScript0.Parent = mas
  26. table.insert(cors,sandbox(LocalScript0,function()
  27. -- put in starter character scripts
  28.  
  29. local MAX_JUMPS = 2;
  30. local MAX_DIVES = 1;
  31. local TIME_BETWEEN_JUMPS = 0.1;
  32.  
  33. local hrp = script.Parent:WaitForChild("HumanoidRootPart");
  34. local head = script.Parent:WaitForChild("Head");
  35. local humanoid = script.Parent:WaitForChild("Humanoid");
  36. local particle = script:WaitForChild("Particle");
  37. particle.Parent = nil;
  38.  
  39. local anim;
  40. if (humanoid.RigType == Enum.HumanoidRigType.R15) then
  41. anim = humanoid:LoadAnimation(script:WaitForChild("Roll_R15"));
  42. else
  43. anim = humanoid:LoadAnimation(script:WaitForChild("Roll_R6"));
  44. end
  45.  
  46. local canJump = true;
  47. local jumpCount = 0;
  48.  
  49. local canDive = true;
  50. local diveCount = 0;
  51. local totalDives = 0;
  52.  
  53. local function createParticle(cf, t)
  54. local part = Instance.new("Part");
  55. part.Size = Vector3.new(4, 4, 4)
  56. part.Anchored = true;
  57. part.CanCollide = false;
  58. part.Transparency = 1;
  59. part.CFrame = cf;
  60. part.Parent = game.Workspace;
  61.  
  62. local clone = particle:Clone();
  63. clone.Enabled = true;
  64. clone.Parent = part;
  65.  
  66. local life = clone.Lifetime;
  67. for i = 0, 1.1, 0.1 do
  68. clone.Lifetime = NumberRange.new((1-i)*life.Min, (1-i)*life.Max + 0.1);
  69. wait(t*0.1);
  70. end
  71.  
  72. game:GetService("Debris"):AddItem(part, t);
  73. end
  74.  
  75. local function onStateChange(old, new)
  76. if (new == Enum.HumanoidStateType.Landed or new == Enum.HumanoidStateType.Swimming or new == Enum.HumanoidStateType.Running or new == Enum.HumanoidStateType.RunningNoPhysics) then
  77. canDive = true;
  78. canJump = true;
  79. jumpCount = 0;
  80. diveCount = 0;
  81. anim:Stop();
  82. elseif (new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.Flying) then
  83. wait(TIME_BETWEEN_JUMPS)
  84. canJump = true;
  85. canDive = true;
  86. end
  87. end
  88.  
  89. local function onJumpRequest()
  90. if (not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Dead) then
  91. return;
  92. end
  93.  
  94. if (canJump and jumpCount < MAX_JUMPS) then
  95. canJump = false;
  96. jumpCount = jumpCount + 1;
  97. humanoid:ChangeState(Enum.HumanoidStateType.Jumping);
  98.  
  99. if (jumpCount > 1) then
  100. if (jumpCount % 2 == 0 or humanoid:GetState() == Enum.HumanoidStateType.Flying) then
  101. anim:Play(nil, nil, 2.5);
  102. end
  103. local z = hrp.CFrame:vectorToObjectSpace(hrp.Velocity).z;
  104. createParticle(hrp.CFrame * CFrame.new(0, -1, 0), .3);
  105. end
  106. end
  107. end
  108.  
  109. local function onInput(input, process)
  110. if (process or not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Dead) then
  111. return;
  112. end
  113.  
  114. if (input.KeyCode == Enum.KeyCode.LeftShift and humanoid:GetState() == Enum.HumanoidStateType.Freefall and canDive and diveCount < MAX_DIVES) then
  115. canDive = false;
  116. diveCount = diveCount + 1;
  117. totalDives = totalDives + 1;
  118.  
  119. anim:Stop();
  120. humanoid:ChangeState(Enum.HumanoidStateType.Flying);
  121. hrp.Velocity = hrp.CFrame:vectorToWorldSpace(Vector3.new(0, humanoid.JumpPower, -humanoid.WalkSpeed*3));
  122. hrp.RotVelocity = hrp.CFrame:vectorToWorldSpace(Vector3.new(-math.rad(135), 0, 0));
  123. createParticle(hrp.CFrame * CFrame.new(0, -1, -3), .3);
  124.  
  125.  
  126. local currentDive = totalDives;
  127. wait(0.5);
  128. if (currentDive == totalDives) then
  129. hrp.RotVelocity = hrp.CFrame:vectorToWorldSpace(Vector3.new(0, 0, 0));
  130. end
  131. end
  132. end
  133.  
  134. local function onTouched(touchingPart, humanoidPart)
  135. if (humanoid:GetState() == Enum.HumanoidStateType.Flying and touchingPart.CanCollide) then
  136. local ray = Ray.new(humanoidPart.Position, -humanoidPart.Velocity * 10);
  137. local hit, pos, normal, material = game.Workspace:FindPartOnRayWithWhitelist(ray, {touchingPart});
  138.  
  139. if (material ~= Enum.Material.Water and material ~= Enum.Material.Air and normal:Dot(Vector3.new(0, 1, 0)) <= 0.5) then
  140. hrp.Velocity = (normal + Vector3.new(0, 1, 0)) * 30;
  141. anim:Play(nil, nil, 2.5);
  142. end
  143.  
  144. humanoid:ChangeState(Enum.HumanoidStateType.Freefall);
  145. end
  146. end
  147.  
  148. if (MAX_DIVES > 0) then
  149. humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false);
  150. humanoid.Touched:Connect(onTouched);
  151. game:GetService("UserInputService").InputBegan:Connect(onInput);
  152. end
  153.  
  154. humanoid.StateChanged:Connect(onStateChange);
  155. game:GetService("UserInputService").JumpRequest:Connect(onJumpRequest);
  156. end))
  157. Animation1.Name = "Roll_R15"
  158. Animation1.Parent = LocalScript0
  159. Animation1.AnimationId = "rbxassetid://2167121830"
  160. ParticleEmitter2.Name = "Particle"
  161. ParticleEmitter2.Parent = LocalScript0
  162. ParticleEmitter2.Rotation = NumberRange.new(-360, 360)
  163. ParticleEmitter2.Color = ColorSequence.new(Color3.new(0.368627, 0.368627, 0.368627),Color3.new(1, 1, 1))
  164. ParticleEmitter2.Enabled = false
  165. ParticleEmitter2.LightEmission = 0.5
  166. ParticleEmitter2.Texture = "http://www.roblox.com/asset/?id=275871881"
  167. ParticleEmitter2.Transparency = NumberSequence.new(1,0,0,1)
  168. ParticleEmitter2.ZOffset = 2
  169. ParticleEmitter2.Size = NumberSequence.new(1.6875,0.25)
  170. ParticleEmitter2.Lifetime = NumberRange.new(0.5, 1.2000000476837)
  171. ParticleEmitter2.Rate = 250
  172. ParticleEmitter2.RotSpeed = NumberRange.new(10, 100)
  173. ParticleEmitter2.SpreadAngle = Vector2.new(45, 45)
  174. ParticleEmitter2.VelocitySpread = 45
  175. Animation3.Name = "Roll_R6"
  176. Animation3.Parent = LocalScript0
  177. Animation3.AnimationId = "rbxassetid://02535928272"
  178. for i,v in pairs(mas:GetChildren()) do
  179. v.Parent = game.StarterPlayer.StarterCharacterScripts
  180. pcall(function() v:MakeJoints() end)
  181. end
  182. mas:Destroy()
  183. for i,v in pairs(cors) do
  184. spawn(function()
  185. pcall(v)
  186. end)
  187. end
Advertisement
Add Comment
Please, Sign In to add comment