I’m making an obby, but I need a way to have like a jump orb there
so basically the player presses space while they’re touching the orb and they like double jump or smth
this is a double jump script that I stole a while ago:
local UserInputService = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local MAX_JUMPS = 2
local TIME_BETWEEN_JUMPS = 0.2
local NumJumps = 0
local CanJumpAgain = false
local function onStateChanged(oldState , newState)
if Enum.HumanoidStateType.Landed == newState then
NumJumps = 0
CanJumpAgain = false
elseif Enum.HumanoidStateType.Freefall == newState then
wait(TIME_BETWEEN_JUMPS)
CanJumpAgain = true
elseif Enum.HumanoidStateType.Jumping == newState then
CanJumpAgain = false
NumJumps += 1
end
end
local function OnJumpRequest()
if CanJumpAgain and NumJumps < MAX_JUMPS then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
local JumpAnimation = Instance.new("Animation")
JumpAnimation.AnimationId = "rbxassetid://9933890080"
local asdf = Animator:loadAnimation(JumpAnimation)
asdf:Play()
end
end
humanoid.StateChanged:Connect(onStateChanged)
UserInputService.JumpRequest:Connect(OnJumpRequest)
then you could put something like this:
local Orb = script.Parent
Orb.Touched:Connect(funtion(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
game.ReplicadedStorage.DoubleJumpScript:Clone()
game.ReplicadedStorage.DoubleJumpScript:Clone().Parent = hit.Parent
end
end)
this might work