RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make the humanoid jump again after pressing spacebar twice with custom animation"
-- local script local player = game:GetService("Players").LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local UserInputService = game:GetService("UserInputService") local jumpCount = 0 local canDoubleJump = true local function onJumpRequest() if jumpCount == 0 then if humanoid:GetState() == Enum.HumanoidStateType.Landed then humanoid:ChangeState(Enum.HumanoidStateType.Jumping) jumpCount = 1 end elseif jumpCount == 1 and canDoubleJump then canDoubleJump = false humanoid:ChangeState(Enum.HumanoidStateType.Jumping) jumpCount = 2 -- Play custom animation local animation = Instance.new("Animation") animation.AnimationId = "rbxassetid://YourAnimationIDHere" local animTrack = humanoid:LoadAnimation(animation) animTrack:Play() end end local function onHumanoidStateChange(oldState, newState) if newState == Enum.HumanoidStateType.Landed then jumpCount = 0 canDoubleJump = true end end UserInputService.JumpRequest:Connect(onJumpRequest) humanoid.StateChanged:Connect(onHumanoidStateChange)