Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a wallclimb system similar to rogue lineages?

Asked by 3 years ago

I was playing rogue lineage a few days ago and I noticed how cool it was just to be able to climb on walls. This wasn't just a custom controller similar to what they did here, but instead you would jump onto the the wall and you would start climbing it instead of changing the gravity. I attempted to replicate this by using BodyVelocity and making an invisible platform whenever the user has stopped moving, but I get a few errors. - sometimes the raycast does not register the wall (possibly could switch to touched, but then I would have to list every wall in the game and that would be a hassel) - the player would keep floating in the air even though clearly the raycast shouldn't be seeing anything (once again, could benefit from touched but im not really sure) - forward/backward cannot be pressed the sametime as left/right movement - (rare) sometimes the player would jump to get over an obstacle and they would start "climbing" (floating)

PLEASE give me tips on my code, I am a new learner of rblx lua so bare with me. (really sorry for the long code)

local function platform(bool)
    if not char:FindFirstChild("platform") and bool == true then
        local platform = Instance.new("Part")
            platform.Name = "platform"
            platform.Size = Vector3.new(2.1, 1, 1)
            platform.Position = Vector3.new(char["Left Leg"].Position.X-.5, char["Left Leg"].Position.Y-1.534, char["Left Leg"].Position.Z)
            platform.CastShadow = false
            platform.Transparency = 1
            platform.Anchored = true
            platform.CanCollide = true
            platform.Parent = char
    elseif bool == false then
        local platform = char:FindFirstChild("platform")

        if platform then
            platform:Destroy()
        end
    end
end

InputService.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.Space and climbing == false and humanoid.WalkSpeed ~= 0 then
        if not char then return end
        local startTime = tick()

        connection_ = InputService.InputBegan:Connect(function(input2)
            if input2.KeyCode == Enum.KeyCode.Space then
                eligible = true
                connection_:Disconnect()
            end
        end)

        repeat wait() until eligible == true or tick()-startTime > .75
        connection_:Disconnect()
        if tick()-startTime > .5 then return end

        local origin = char:WaitForChild("Head").Position
        local result = workspace:Raycast(origin, direction, params)

        if result and climbing == false then
            print("found")
            humanoid.AutoRotate = false
            climbing = true
            local part = result.Instance    

            -- play anim here
            local newTime = tick()

            platform(true)

            connection = InputService.InputBegan:Connect(function(input)
                if tick()-newTime >= 7.5 then
                    connection:Disconnect()
                    destroyAll()
                    platform(false)
                    humanoid.AutoRotate = true
                    return
                elseif input.KeyCode == Enum.KeyCode.W then
                    platform(false)
                    local forward = Instance.new("BodyVelocity", HRP)
                        forward.Name = "forward"
                        forward.Velocity = Vector3.new(0,15,0)

                    repeat wait() result = workspace:Raycast(origin, direction, params) until not result or not char or isDown(Enum.KeyCode.W) == false or tick()-newTime >= 7.5

                    if not char or tick()-newTime >= 7.5 then connection:Disconnect() destroyAll() platform(false) humanoid.AutoRotate = true return end

                    if not result then
                        connection:Disconnect()
                        forward.Velocity = Vector3.new(15, 12, 0)
                        wait(.5)
                        destroyAll()
                        climbing = false
                        humanoid.AutoRotate = true
                    else
                        forward:Destroy()
                        platform(true)
                    end
                elseif input.KeyCode == Enum.KeyCode.S then
                    platform(false)
                    local backward = Instance.new("BodyVelocity", HRP)
                        backward.Name = "backward"
                        backward.Velocity = Vector3.new(0,-15,0)

                    repeat wait() until isDown(Enum.KeyCode.S) == false or tick()-newTime >= 7.5

                    if tick()-newTime >= 7.5 then connection:Disconnect() destroyAll() platform(false) humanoid.AutoRotate = true return end

                    backward:Destroy()

                    platform(true)
                end

there is more but its really long (just for pressing S, D and A.)

0
trash post iuclds 720 — 3y
0
i'm going to ban you iucids Fifkee 2017 — 3y

Answer this question