Im trying to make a double jump ability but whenever the player jumps it fires it but does not double jump? I do not know what is happening here.
Here is also a video of the problem:
local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character
local humanoid
local canDoubleJump = false
local hasDoubleJumped = false
local DOUBLE_JUMP_POWER_MULTIPLIER = 1.5
function onJumpRequest()
if not character or not humanoid or not character:IsDescendantOf(workspace) or
humanoid:GetState() == Enum.HumanoidStateType.Dead then
return
end
if canDoubleJump and not hasDoubleJumped then
if localPlayer.folder.Doublejump.Value == false then
return
end
hasDoubleJumped = true
humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
local idk = game.ReplicatedStorage.Poof:Clone()
idk.Position = character.HumanoidRootPart.Position
idk.Parent = workspace
task.wait(0.5)
idk:Destroy()
local value = 0
while true do
wait(0.1)
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.Frame.Visible = true
value += 0.1
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.Frame.Position += UDim2.new(0,0,0.01,0)
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.TextLabel.Visible = true
local newvalue = math.round(value / 100) * 100
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.TextLabel.Text = string.format("%0.1f", 10 - value)
if game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.Frame.Position.Y.Scale >= 1 then
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.Frame.Visible = false
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.Frame.Position = UDim2.new(0,0,0,0)
game.Players.LocalPlayer.PlayerGui.Stuff.Ability.Jump.CanvasGroup.TextLabel.Visible = false
break
end
end
end
end
local function characterAdded(newCharacter)
character = newCharacter
humanoid = newCharacter:WaitForChild("Humanoid")
hasDoubleJumped = false
canDoubleJump = false
oldPower = humanoid.JumpPower
humanoid.StateChanged:connect(function(old, new)
if new == Enum.HumanoidStateType.Landed then
if localPlayer.folder.Doublejump.Value == false then return end
game.ReplicatedStorage.Abilites.Jump2:FireServer()
canDoubleJump = false
hasDoubleJumped = false
humanoid.JumpPower = oldPower
elseif new == Enum.HumanoidStateType.Freefall then
canDoubleJump = true
end
end)
end
if localPlayer.Character then
characterAdded(localPlayer.Character)
end
localPlayer.CharacterAdded:connect(characterAdded)
UserInputService.JumpRequest:connect(onJumpRequest)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.