#climb script

7 messages · Page 1 of 1 (latest)

fresh needle
#

In my script, I made it so that when you touch an edge that’s too high, you will latch onto it and if you click space after that, it will make your character do a jump animation and pull yourself up but when I jump, I float like 10 studs up before falling instead of smoothly doing a normal jump. Is there any way to fix this?

#
local RollMutipleSpeed = 1.8
local MaxRunSpeed = 25
local AccelerationRate = 5
local DecelerationRate = 10

local UserGameSettings = UserSettings():GetService("UserGameSettings")
local Players = game.Players
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local DefaultC0 = Character:WaitForChild("HumanoidRootPart"):FindFirstChildWhichIsA("Motor6D").C0
local Humanoid = Character:WaitForChild("Humanoid")

local Idling = true
local Holding = false
local Running = false
local Moving = false
local Rolling = false
local CurrentSpeed = 16
local IsSliding = false

local Orientation = {
    ["X"] = 0;
    ["Y"] = 0;
}

local moveInput = {
    [Enum.KeyCode.W] = {"X", 1};
    [Enum.KeyCode.S] = {"X", -1};
    [Enum.KeyCode.D] = {"Y", -1};
    [Enum.KeyCode.A] = {"Y", 1};
}

local IdleAnimationId = "rbxassetid://18366101600"
local JumpAnimationId = "rbxassetid://18366346934"
local FallAnimationId = "rbxassetid://18366349994"

local Animations = {
    ["Hold"] = "rbxassetid://18365224698";
    ["Run"] = "rbxassetid://18365735389";
    ["Roll"] = "rbxassetid://18365261075";
    ["Climb"] = "rbxassetid://18365055057";
    ["Idle"] = IdleAnimationId;
    ["Jump"] = JumpAnimationId;
    ["Fall"] = FallAnimationId;
}

UserGameSettings.RotationType = Enum.RotationType.CameraRelative 

for name, id in pairs(Animations) do
    local anim = Instance.new("Animation")
    anim.AnimationId = id
    Animations[name] = Humanoid:LoadAnimation(anim)
end ```
#
    if not Character.HumanoidRootPart:FindFirstChildWhichIsA("Motor6D") then return end
    if Direction == nil then return end

    if InputState == "Began" and not Holding then
        Orientation[Direction[1]] = TiltDegree * Direction[2]
    else
        if Orientation[Direction[1]] == TiltDegree * Direction[2] or not Idling then
            Orientation[Direction[1]] = 0
        end
    end

    local info = TweenInfo.new(0.3, Enum.EasingStyle.Linear)
    local HandledC0 = DefaultC0 * CFrame.Angles(math.rad(Orientation.X), math.rad(Orientation.Y), 0)
    TweenService:Create(Character.HumanoidRootPart:FindFirstChildWhichIsA("Motor6D"), info, {C0 = HandledC0}):Play()
end

function Roll()
    if Humanoid.MoveDirection == Vector3.new(0,0,0) or not Idling then return end

    Idling = false
    Rolling = true
    IsSliding = true

    if Running then
        Humanoid.WalkSpeed = MaxRunSpeed * RollMutipleSpeed
    else
        Humanoid.WalkSpeed = 16 * RollMutipleSpeed
    end

    UserGameSettings.RotationType = Enum.RotationType.MovementRelative

    Animations.Roll:Play()
    Animations.Roll.Stopped:Wait()

    while Humanoid.WalkSpeed > CurrentSpeed do
        Humanoid.WalkSpeed = Humanoid.WalkSpeed - DecelerationRate * RunService.RenderStepped:Wait()
    end

    UserGameSettings.RotationType = Enum.RotationType.CameraRelative

    Idling = true
    Rolling = false
    IsSliding = false
end ```
#
    if not Holding then return end

    Holding = false

    local BodyVelocity = Instance.new("BodyVelocity", Character.HumanoidRootPart)
    BodyVelocity.MaxForce = Vector3.new(1,1,1) * math.huge
    BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 10 + Vector3.new(0, 30, 0)

    Character.HumanoidRootPart.Anchored = false
    Humanoid.AutoRotate = true

    Animations.Hold:Stop()
    Animations.Jump:Play()
    Animations.Jump.Stopped:Wait()

    BodyVelocity:Destroy()

    Idling = true
end

function HoldTheEdge()
    Holding = true
    Idling = false

    Character.HumanoidRootPart.Anchored = true
    Humanoid.AutoRotate = false

    Animations.Hold:Play()
end

function CheckIfNearTheEdge()
    if not Character:FindFirstChild("Head") then return end

    local LookRay = Ray.new(Character.Head.Position, Character.Head.CFrame.LookVector * 1)
    local Part = workspace:FindPartOnRay(LookRay, Character)
    if Part and Idling and not Holding then
        if Character.Head.Position.Y >= Part.Position.Y + (Part.Size.Y / 2) - 1
            and Humanoid.FloorMaterial == Enum.Material.Air
        then
            HoldTheEdge()
        end
    end
end

function UpdateSpeed()
    if Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
        CurrentSpeed = math.min(CurrentSpeed + AccelerationRate * RunService.RenderStepped:Wait(), MaxRunSpeed)
    else
        CurrentSpeed = math.max(CurrentSpeed - DecelerationRate * RunService.RenderStepped:Wait(), 16)
    end
    Humanoid.WalkSpeed = CurrentSpeed
end

function CheckIfRunning()
    local isRunning = Humanoid.MoveDirection ~= Vector3.new(0,0,0)

    if isRunning ~= Running then
        Running = isRunning

        if Running then
            Animations.Run:Play() ```
#
        else
            Animations.Run:Stop()
            TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.3, Enum.EasingStyle.Linear), {FieldOfView = 70}):Play()
        end
    end

    if not Running and not Rolling then
        Animations.Idle:Play()
    else
        Animations.Idle:Stop()
    end

    UpdateSpeed()
end

UserInputService.InputBegan:Connect(function(input, chat)
    if chat then return end

    if input.KeyCode == Enum.KeyCode.Space then
        return Jump()
    elseif input.KeyCode == Enum.KeyCode.E then
        return Roll()
    end

    CharacterTween(moveInput[input.KeyCode], "Began")
end)

UserInputService.InputEnded:Connect(function(input, chat)
    if chat then return end

    CharacterTween(moveInput[input.KeyCode], "Ended")
end) ```
#
    CheckIfNearTheEdge()
    CheckIfRunning()
end)

Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
    if not Humanoid.FloorMaterial then
        Animations.Fall:Play()
    else
        Animations.Fall:Stop()
    end
end)

Humanoid.StateChanged:Connect(function(oldState, newState)
    if newState == Enum.HumanoidStateType.Jumping then
        Animations.Jump:Play()
    end
end) ```
#

That’s my whole script (sorry if it’s too long)