First off
I typed the code in a local script that I inserted into StarterPlayerScripts. This is my code,
local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character
local humanoid
local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.2
local DOUBLE_JUMP_POWER_MULTIPLIER = 2
function onJumpRequest()
if not character or not humanoid or not charaacter:IsDescendantOf(workspace) or
humanoid:GetState() == Enum.HumanoidStateType.Dead then
return
end
if canDoubleJump and not hasDoubleJumped then
hasDoubleJumped = true
humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
humanoid:ChangedState(Enum.HumanoidStateType.Jumping)
end
end
local function CharacterAdded(newCharacter)
character = newCharacter(newCharacter)
humanoid = newCharacter:WaitForChild("humanoid")
hasDoubleJumped = false
canDoubleJump = false
oldPower = humanoid.JumpPower
humanoid.StateChanged:connect(function(old,new)
if new == Enum.HumanoidStateType.Freefall then
canDoubleJump = false
hasDoubleJumped = false
humanoid.JumpPower = oldPower
elseif new == Enum.HumanoidStateType.Landed then
wait(TIME_BETWEEN_JUMPS)
hasDoubleJumped = false
end
end)
end
if localPlayer.character then
CharacterAdded(localPlayer.character)
end
localPlayer.CharacterAdded:connect(CharacterAdded())
UserInputService.JumpRequest:connect(onJumpRequest)
I started the play test in Studio and every time I pressed the space bar to jump it doesn't work, any help?

1 comment
Please take advantage of the Search bar prior to posting questions. There may be a chance someone has already answered your question in the past .