Advertisement
BladefuryDood

Advanced Movement (R15) Part 1

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