of     1   

Korniak
#190007860Sunday, May 29, 2016 8:08 PM GMT

My objective is to be able to double jump, but you can't double-jump until the cooldown time of 5 seconds is up. Here is what I've got, and I'm stumped. 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 local LastPressed UserInputService.JumpRequest:connect(function() 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 hasDoubleJumped = true humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER humanoid:ChangeState(Enum.HumanoidStateType.Jumping) end end) local function characterAdded(newCharacter) character = newCharacter humanoid = newCharacter:WaitForChild("Humanoid") hasDoubleJumped = false canDoubleJump = false oldPower = humanoid.JumpPower LastPressed = tick() humanoid.StateChanged:connect(function(old, new) if new == Enum.HumanoidStateType.Landed then canDoubleJump = false hasDoubleJumped = false humanoid.JumpPower = oldPower elseif new == Enum.HumanoidStateType.Jumping and tick() - LastPressed <= 5 then wait(TIME_BETWEEN_JUMPS) canDoubleJump = true LastPressed = tick() end end) end Korniak, the antler dude
Korniak
#190007976Sunday, May 29, 2016 8:10 PM GMT

I cannot double jump at all with what I have done. Korniak, the antler dude
Thedagz
#190008138Sunday, May 29, 2016 8:12 PM GMT

Whats the error?
Korniak
#190008489Sunday, May 29, 2016 8:16 PM GMT

Restarted 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 character: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:ChangeState(Enum.HumanoidStateType.Jumping) end end local function characterAdded(newCharacter) character = newCharacter humanoid = newCharacter:WaitForChild("Humanoid") hasDoubleJumped = false canDoubleJump = false oldPower = humanoid.JumpPower LastPressed = tick() humanoid.StateChanged:connect(function(old, new) if new == Enum.HumanoidStateType.Landed then canDoubleJump = false hasDoubleJumped = false humanoid.JumpPower = oldPower elseif new == Enum.HumanoidStateType.Jumping and tick() - LastPressed <= 5 then wait(TIME_BETWEEN_JUMPS) canDoubleJump = true LastPressed = 0 end end) end if localPlayer.Character then characterAdded(localPlayer.Character) end localPlayer.CharacterAdded:connect(characterAdded) UserInputService.JumpRequest:connect(onJumpRequest) Error is now that it will double jump once, but after that it won't do it again. Korniak, the antler dude
Thedagz
#190008539Sunday, May 29, 2016 8:16 PM GMT

You didn't put a event for the character added function paste this at the very bottom localPlayer.CharacterAdded:connect(characterAdded)
Korniak
#190008578Sunday, May 29, 2016 8:17 PM GMT

read my restarted code Korniak, the antler dude
Korniak
#190008621Sunday, May 29, 2016 8:17 PM GMT

and my objective Korniak, the antler dude
Korniak
#190009545Sunday, May 29, 2016 8:28 PM GMT

bump Korniak, the antler dude
boatbomber
#190010108Sunday, May 29, 2016 8:36 PM GMT

local UserInputService = game:GetService("UserInputService") local localPlayer = game.Players.LocalPlayer local character local humanoid local canDoubleJump = false local hasDoubleJumped = false local oldPowerlocal TIME_BETWEEN_JUMPS = 0.2local DOUBLE_JUMP_POWER_MULTIPLIER = 2 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 hasDoubleJumped = true humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER humanoid:ChangeState(Enum.HumanoidStateType.Jumping) 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 canDoubleJump = false hasDoubleJumped = false humanoid.JumpPower = oldPower elseif new == Enum.HumanoidStateType.Freefall then wait(TIME_BETWEEN_JUMPS) canDoubleJump = true end end) end if localPlayer.Character then characterAdded(localPlayer.Character) end localPlayer.CharacterAdded:connect(characterAdded) UserInputService.JumpRequest:connect(onJumpRequest) You're welcome.
Korniak
#190010539Sunday, May 29, 2016 8:42 PM GMT

wow did you not read what i wanted it to do Korniak, the antler dude
Korniak
#190011002Sunday, May 29, 2016 8:48 PM GMT

OBJECTIVE RESTATED: I want the player to double-jump with a cooldown of 5 seconds. Korniak, the antler dude
Korniak
#190012029Sunday, May 29, 2016 9:02 PM GMT

bump Korniak, the antler dude
Korniak
#190013371Sunday, May 29, 2016 9:16 PM GMT

bump Korniak, the antler dude
Korniak
#190014320Sunday, May 29, 2016 9:27 PM GMT

bump again Korniak, the antler dude
boatbomber
#190028683Monday, May 30, 2016 12:14 AM GMT

local UserInputService = game:GetService("UserInputService") local LocalPlayer = game:GetService("Players").LocalPlayer local Character local Humanoid local DoubleJump = false local Debounce = false UserInputService.JumpRequest:connect(function() if not Character or not Humanoid or not Character:IsDescendantOf(workspace) or Humanoid:GetState() == Enum.HumanoidStateType.Dead then return end if not Debounce then Debounce = true if not DoubleJump and Humanoid:GetState() == Enum.HumanoidStateType.Freefall then local torso = Character:FindFirstChild("Torso") if torso then torso.Velocity = Vector3.new(torso.Velocity.X, Humanoid.JumpPower * 1.01, torso.Velocity.Z) DoubleJump = true end end wait(0.3) Debounce = false end end) local function CharacterAdded(char) Character = char Humanoid = char:WaitForChild("Humanoid") Humanoid.StateChanged:connect(function(_, new) if new == Enum.HumanoidStateType.Landed then DoubleJump = false end end) Humanoid.Died:connect(function() DoubleJump = false end)end if LocalPlayer.Character then CharacterAdded(LocalPlayer.Character) end LocalPlayer.CharacterAdded:connect(CharacterAdded) Just change the debounce to your cooldown. Happy now?
boatbomber
#190028891Monday, May 30, 2016 12:16 AM GMT

local UserInputService = game:GetService("UserInputService") local LocalPlayer = game:GetService("Players").LocalPlayer local Character local Humanoid local DoubleJump = false local Debounce = false UserInputService.JumpRequest:connect(function() if not Character or not Humanoid or not Character:IsDescendantOf(workspace) or Humanoid:GetState() == Enum.HumanoidStateType.Dead then return end if not Debounce then Debounce = true if not DoubleJump and Humanoid:GetState() == Enum.HumanoidStateType.Freefall then local torso = Character:FindFirstChild("Torso") if torso then torso.Velocity = Vector3.new(torso.Velocity.X, Humanoid.JumpPower * 1.01, torso.Velocity.Z) DoubleJump = true end end wait(5) Debounce = false end end) local function CharacterAdded(char) Character = char Humanoid = char:WaitForChild("Humanoid") Humanoid.StateChanged:connect(function(_, new) if new == Enum.HumanoidStateType.Landed then DoubleJump = false end end) Humanoid.Died:connect(function() DoubleJump = false end)end if LocalPlayer.Character then CharacterAdded(LocalPlayer.Character) end LocalPlayer.CharacterAdded:connect(CharacterAdded) There 5 second cooldown. Place in StarterPlayerScripts. You owe me one bro. Like and fave my game plz. https://www.roblox.com/games/346407590/Distance-Alpha
Korniak
#190033630Monday, May 30, 2016 1:20 AM GMT

nope i owe you nothing, plus i probably fixed it myself

    of     1