Hello everyone,
I am trying to make a custom 2.5d character controller, but I have no idea how to implement double jumping.
This is my script at the moment:
game.ReplicatedStorage.movementEvent.jumpEvent.OnServerEvent:Connect(function(plr)
local function jump()
local velocity = plr.Character.HumanoidRootPart.LinearVelocity --This is the body mover I use for moving the character
local jumpPower = 50
velocity.VectorVelocity = Vector3.new(velocity.VectorVelocity.X, jumpPower, 0)
for i = 1, 25 do
velocity.VectorVelocity = Vector3.new(velocity.VectorVelocity.X, jumpPower - i * 4, 0)
wait()
end
end
if plr.Character.Humanoid.FloorMaterial then
jump()
plr.Character.Properties.doubleJump.Value = true
elseif plr.Character.Properties.doubleJump.Value == true then
jump()
plr.Character.Properties.doubleJump.Value = false
end
end)
The problem is that if the player double jumps while the jump()
function is still running, the player’s character will kinda float in the air and then land on the floor.
How can I fix it?