Help with smoother mechanics

Hey there :)) A pal helped me with a wall jumping script, but it’s not the best rn. Wall jumping is supposed to be like the extension of your arm, a smooth, natural feeling mechanic. But currently, it requires some effort to succesfully perform that action. I’m going to leave the script here, feel free to test it out. Hoping for feedback on how to smoothen the mechanic!

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local humroot = character:WaitForChild("HumanoidRootPart")

local deb = false

local function raycast()
    local raycastParams = RaycastParams.new()
    raycastParams.FilterType = Enum.RaycastFilterType.Exclude
    raycastParams.FilterDescendantsInstances = {character}

    local raycastOrigin = humroot.Position
    local raycastDistance = 5 -- Distance for detection
    
    local raycastDirections = {
        humroot.CFrame.LookVector, -- Forward
        humroot.CFrame.RightVector, -- Right
        -humroot.CFrame.RightVector, -- Left
        -humroot.CFrame.LookVector -- Backward
    }
    local raycastHit = nil
    for _, direction in ipairs(raycastDirections) do
        raycastHit = workspace:Raycast(raycastOrigin, direction * raycastDistance, raycastParams)
        if raycastHit then
            break
        end
    end

    if raycastHit and hum:GetState() == Enum.HumanoidStateType.Freefall and not deb then
        deb = true
        hum:ChangeState(Enum.HumanoidStateType.Jumping)

        local ejectionDirection = (humroot.CFrame.Position - raycastHit.Position).Unit + Vector3.new(0, 1, 0)

        local bodVelocity = Instance.new("BodyVelocity", humroot)
        bodVelocity.Velocity = ejectionDirection * 25
        bodVelocity.MaxForce = Vector3.new(100000, 100000, 100000)
        bodVelocity.P = 1250
        wait(0.2)
        bodVelocity:Destroy()
        wait(0.1)
        deb = false
    end
end

uis.JumpRequest:Connect(raycast)
2 Likes

i’ll see what I can do! (extra characters)

nothing :confused:
maybe you just need to find another way to do it?

alr, I’ll leave this post as is to see what others have to offer

I tried your script, and it didn’t feel like this at all
It was almost too easy to walljump because you could do it even when you aren’t midair
It’s hard to understand what “smoothen” means because it really depends on the specifics of how exactly the walljump should behave, but here are some things I can suggest:

make it so you have to be midair to walljump
push the player forward so that you can gain speed
maybe pull the player closer to the wall before pushing them off

If you want any more help I would like to know more what you want out of a walljump mechanic, hope this helps