This is a really big problem in my game and I really hope someone would solve it, it would be wonderful! So in my game I used a wall jump script that lets a player jump off special walls, and a script that lets players double jump. The problem is that when a player tries to wall jump, the double jump script overrides the wall jump script, and only makes a double jump. What I want here is that it double jumps when it's not against a wall, and when the player is against a wall, don't double jump and wall jump instead.
This is the wall jump script:
local player = game.Players.LocalPlayer player.CharacterAdded:wait() local character = player.Character local torso = character:WaitForChild("LowerTorso") local mouse = player:GetMouse() local humanoid = character:WaitForChild("Humanoid") local ReplicatedStorage = game:GetService("ReplicatedStorage") p = ReplicatedStorage:FindFirstChild("Kapow") local tweeninfo = TweenInfo.new(0.85) local ts = game:GetService("TweenService") local goal = {} goal.Size = Vector3.new(11, 11, 11) goal.Transparency = 1 local lastwall = nil function onJump() if humanoid.Jump == true then local ray = Ray.new( torso.CFrame.p, torso.CFrame.lookVector *2 ) local hit, position, normal = workspace:FindPartOnRay(ray, character) if hit then if hit ~= lastwall then if hit.Name == "WallJump1" then local p2 = p:Clone() local tween = ts:Create(p2, tweeninfo, goal) p2.Parent = workspace p2.Position = humanoid.Parent.HumanoidRootPart.Position tween:Play() print("walljump") local animation = humanoid:LoadAnimation(script.Animation) animation:Play() script.Sound:Play() local velo = Instance.new("BodyVelocity",torso) velo.MaxForce = Vector3.new(400000,400000,400000) velo.Velocity = -torso.CFrame.lookVector*20 + Vector3.new(0,35,35) game.Debris:AddItem(velo,0.1) lastwall = hit wait(1) lastwall = nil elseif hit.Name == "WallJump2" then print("walljump") local p2 = p:Clone() local tween = ts:Create(p2, tweeninfo, goal) p2.Parent = workspace p2.Position = humanoid.Parent.HumanoidRootPart.Position tween:Play() local animation = humanoid:LoadAnimation(script.Animation) animation:Play() script.Sound:Play() local velo = Instance.new("BodyVelocity",torso) velo.MaxForce = Vector3.new(400000,400000,400000) velo.Velocity = -torso.CFrame.lookVector*20 + Vector3.new(0,35,-35) game.Debris:AddItem(velo,0.1) lastwall = hit wait(1) lastwall = nil end end end end end humanoid.Changed:Connect(onJump)
And this is the double jump script:
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.1 local DOUBLE_JUMP_POWER_MULTIPLIER = 0.6 local ReplicatedStorage = game:GetService("ReplicatedStorage") p = ReplicatedStorage:FindFirstChild("Twirlpoof") local tweeninfo = TweenInfo.new(0.85) local ts = game:GetService("TweenService") local goal = {} goal.Size = Vector3.new(12, 3, 12) goal.Transparency = 1 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 local p2 = p:Clone() local tween = ts:Create(p2, tweeninfo, goal) p2.Parent = workspace p2.Position = humanoid.Parent.HumanoidRootPart.Position tween:Play() local animation = humanoid:LoadAnimation(script.Animation) animation:Play() 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)