Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local Player = game.Players.LocalPlayer
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- local RootPart = Character:WaitForChild("HumanoidRootPart")
- local boostWindow = 1
- local speedMultiplier = 1.15
- local maxSpeed = 200
- local baseGravity = workspace.Gravity
- local gravityReductionStep = 1
- local minGravity = 100
- local currentSpeedBoost = 0
- local lastLandTime = 0
- local canBoost = false
- local direction = Vector3.new(0, 0, 0)
- local function resetBoostAndGravity()
- currentSpeedBoost = 0
- canBoost = false
- workspace.Gravity = baseGravity
- end
- local function onLanding()
- canBoost = true
- lastLandTime = tick()
- if workspace.Gravity > minGravity then
- workspace.Gravity = math.max(workspace.Gravity - gravityReductionStep, minGravity)
- end
- end
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.KeyCode == Enum.KeyCode.Space then
- local timeSinceLand = tick() - lastLandTime
- if canBoost and timeSinceLand <= boostWindow then
- local moveDirection = Humanoid.MoveDirection
- if moveDirection.Magnitude > 0 then
- local currentVelocity = RootPart.Velocity
- currentSpeedBoost = math.min(currentSpeedBoost * speedMultiplier + 10, maxSpeed)
- local boostVelocity = moveDirection.Unit * currentSpeedBoost
- RootPart.Velocity = Vector3.new(boostVelocity.X, currentVelocity.Y, boostVelocity.Z)
- direction = moveDirection.Unit
- else
- resetBoostAndGravity()
- end
- Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
- canBoost = false
- else
- resetBoostAndGravity()
- end
- end
- end)
- RunService.RenderStepped:Connect(function()
- if currentSpeedBoost > 0 then
- local moveDirection = Humanoid.MoveDirection
- if moveDirection.Magnitude > 0 then
- local currentVelocity = RootPart.Velocity
- local boostVelocity = direction * currentSpeedBoost
- RootPart.Velocity = Vector3.new(boostVelocity.X, currentVelocity.Y, boostVelocity.Z)
- else
- resetBoostAndGravity()
- end
- end
- end)
- Humanoid.StateChanged:Connect(function(_, newState)
- if newState == Enum.HumanoidStateType.Landed then
- onLanding()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment