Need some help using BodyMovers for a wall jump mechanic

Hello!

I apologize if this belongs in #building-support, however I am doing this via a script so I believe it belongs here.

Anyway, I am currently working on a body jump mechanic that allows the player to jump and hopefully push them towards the direction the torso is facing.

The issue comes from the pushing them in the direction part. I got the player to move upwards, however I don’t know what body mover to use to achieve this.

Here’s what I have so far:

local userInputService = game:GetService('UserInputService')
local chr = game.Players.LocalPlayer.Character

for i,v in pairs(workspace:GetDescendants()) do
    if v:FindFirstChild('_WallJump') then
        local deb = false
        local inpdeb = false
        v.Touched:Connect(function(h)
            if not deb then
                print('toch')
                if h.Parent == chr and h == chr.HumanoidRootPart then
                    local torso = chr.Torso
                    torso.Anchored = true
                    deb = true
                    torso.CFrame = torso.CFrame * CFrame.Angles(0, math.rad(180), 0)
                    connection = userInputService.InputBegan:Connect(function(key, isSystemReserved)
                        if not isSystemReserved and not inpdeb then
                            if key.KeyCode == Enum.KeyCode.Space then
                                inpdeb = true
                                torso.Anchored = false
                                local bt = torso:FindFirstChild('BodyVelocity')
                                if bt then
                                    bt:Destroy()
                                end
                                torso.CFrame = torso.CFrame * CFrame.Angles(0, math.rad(180), 0)
                                bt = Instance.new('BodyVelocity', chr.HumanoidRootPart)
                                bt.MaxForce = Vector3.new(0, 40000, 0)
                                bt.Velocity = Vector3.new(0, 50, 0)
                                wait(.1)
                                bt:Destroy()
                                inpdeb = false
                                deb = false
                                connection:Disconnect()
                            end
                        end
                    end)
                end
            end
        end)
    end
end

TIA for any help/guidance! :smile:

Have you tried any of them?
I ask as I find I have learned faster if I try stuff and then If having tried and failed ask for help with examples of what I have tried.
Why not give it a go. You might surprise yourself. :slight_smile:

1 Like

Yeah, tried BodyThrust and it ended up not being consistent at all. Also tried VectorForce and it seemed not to work unfortunately, just sent the player in the wrong direction.