#How do i made the slide stay un till i un hold the button? and will speed up when slide down hills

18 messages · Page 1 of 1 (latest)

harsh spindle
lucid nexus
#

My internet is a bit little off its blurred

lucid nexus
# harsh spindle
local UIS = game:GetService("UserInputService")
local char = script.Parent

local slideAnim = Instance.new("Animation")
local ca = rbxassetid -- keep your existing animation ID

local isSliding = false

UIS.InputBegan:Connect(function(input, gameprocessed)
    if gameprocessed then return end
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSliding = true
        local playAnim = char.Humanoid:LoadAnimation(slideAnim)
        playAnim:Play()
        
        while isSliding do
            local rayOrigin = char.HumanoidRootPart.Position
            local rayDirection = Vector3.new(0, -10, 0)
            local ray = Ray.new(rayOrigin, rayDirection)
            local hitPart, hitPoint, hitNormal = workspace:FindPartOnRay(ray)
            
            if hitPart then
                -- Calculate slope angle
                local slopeAngle = math.acos(hitNormal.Y)
                local slopeMultiplier = math.sin(slopeAngle) * 2
                
                local slide = script.Slide
                slide.Parent = char.HumanoidRootPart
                slide.MaxForce = Vector3.new(1,0,1) * 10000
                -- Base velocity plus slope adjustment
                local baseVelocity = 0.7
                slide.Velocity = char.HumanoidRootPart.CFrame.LookVector * 
                    (baseVelocity + slopeMultiplier)
            end
            task.wait(0.1)
        end
    end
end)

UIS.InputEnded:Connect(function(input, gameprocessed)
    if gameprocessed then return end
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSliding = false
        if char.HumanoidRootPart:FindFirstChild("Slide") then
            char.HumanoidRootPart.Slide:Destroy()
        end
    end
end)```
harsh spindle
#

ty

lucid nexus
#

Did it work?

harsh spindle
#

no it didnt work

#

now i cant slide

lucid nexus
fallen wave
# lucid nexus

this makes it only work once lua local slide = script.Slide slide.Parent = char.HumanoidRootPart

#

should be a clone instead of directly moving it

#

alternatively use instance.new

harsh spindle
#

thanks it work now

fallen wave
#

also also lua local playAnim = char.Humanoid:LoadAnimation(slideAnim) playAnim:Play() should only load the animation once, this loads it each time.

#

also the stop sliding doesnt stop playing this animation

lucid nexus
#

Fix it Pyro 👍

fallen wave
#

homework for @harsh spindle