#Im not sure how to make a shift to slide script

110 messages · Page 1 of 1 (latest)

bronze marsh
#

I have a script for sliding and crouching and sprinting but I cannot figure out how to make crouching not available when you run and sliding available when you do run

gleaming agate
#

With a boolvalue, If your running set it to true, not set it to false. Then when you crouch it will slide or crouch depending on if your running.

tepid sigil
bronze marsh
tepid sigil
#

send me sprinting, crouching and sliding scripts

tepid sigil
bronze marsh
#

local UIS = game:GetService("UserInputService")
local char = script.Parent

local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://139682445589811" --

local keybind = Enum.KeyCode.LeftControl --
local canslide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end

if input.KeyCode == keybind then
    canslide = false
    
    local playAnim = char.Humanoid:LoadAnimation(slideAnim)
    playAnim:Play()
    
    local slide = Instance.new("BodyVelocity")
    slide.MaxForce = Vector3.new(1,0,1) * 30000
    slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
    slide.Parent = char.HumanoidRootPart
    
    for count = 1, 8 do
        wait(0.1)
        slide.Velocity*= 0.7
    end
    playAnim:Stop()
    slide:Destroy()
    canslide = true
end

end)

#

slide

#

local UIS = game:GetService("UserInputService")
local char = script.Parent

local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://139682445589811" --

local keybind = Enum.KeyCode.LeftControl --
local canslide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end

if input.KeyCode == keybind then
    canslide = false
    
    local playAnim = char.Humanoid:LoadAnimation(slideAnim)
    playAnim:Play()
    
    local slide = Instance.new("BodyVelocity")
    slide.MaxForce = Vector3.new(1,0,1) * 30000
    slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
    slide.Parent = char.HumanoidRootPart
    
    for count = 1, 8 do
        wait(0.1)
        slide.Velocity*= 0.7
    end
    playAnim:Stop()
    slide:Destroy()
    canslide = true
end

end)

#

crpuch

tepid sigil
#

sprint?

bronze marsh
#

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)--
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 26
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://9040323497'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
end
end)

#

sorry

tepid sigil
#

alright give me some time

bronze marsh
#

Take as much time as you need

tepid sigil
#

sliding ~

local UIS = game:GetService("UserInputService")
local char = script.Parent
local Humanoid = char:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)

local slideKey = Enum.KeyCode.LeftControl
local canSlide = true

UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if not canSlide or not _G.isSprinting then return end

    if input.KeyCode == slideKey then
        canSlide = false

        local slideAnim = Instance.new("Animation")
        slideAnim.AnimationId = "rbxassetid://139682445589811"

        local playAnim = Animator:LoadAnimation(slideAnim)
        playAnim:Play()

        local slide = Instance.new("BodyVelocity")
        slide.MaxForce = Vector3.new(1,0,1) * 30000
        slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
        slide.Parent = char.HumanoidRootPart

        for count = 1, 8 do
            wait(0.1)
            slide.Velocity *= 0.7
        end

        playAnim:Stop()
        slide:Destroy()
        canSlide = true
    end
end)```
# crouching ~
```lua
local UIS = game:GetService("UserInputService")
local char = script.Parent
local Humanoid = char:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)

local crouchKey = Enum.KeyCode.LeftControl
local canCrouch = true

UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if not canCrouch or _G.isSprinting then return end

    if input.KeyCode == crouchKey then
        canCrouch = false

        local crouchAnim = Instance.new("Animation")
        crouchAnim.AnimationId = "rbxassetid://139682445589811"

        local playAnim = Animator:LoadAnimation(crouchAnim)
        playAnim:Play()

        wait(0.5)
        playAnim:Stop()
        canCrouch = true
    end
end)```
# sprinting ~
```lua
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local isSprinting = false

local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSprinting = true
        _G.isSprinting = true
        Humanoid.WalkSpeed = 26
        
        local sprintAnim = Instance.new("Animation")
        sprintAnim.AnimationId = "rbxassetid://9040323497"

        local PlayAnim = Animator:LoadAnimation(sprintAnim)
        PlayAnim:Play()
    end
end)

UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSprinting = false
        _G.isSprinting = false
        Humanoid.WalkSpeed = 16

        for _, anim in pairs(Animator:GetPlayingAnimationTracks()) do
            anim:Stop()
        end
    end
end)```
small explanation ~ i fixed the animations by using an animator so they don’t break sprinting disables crouching to avoid weird movement sliding only works while sprinting to make it feel smooth animations stop properly so nothing stacks or bugs out
if you don't understand any parts of the code feel free to ask or if something doesn't work
#

it only needed couple of lines to add and change ^

#

uh let me fix 1 or 2 mistakes one sec

#

there @bronze marsh give it a try

#

i used an animator to play animations so they work right used a global sprinting variable to control crouching and sliding also used input detection to check when to start or stop actions and body velocity to make sliding feel real

#

(if it doesn't work i'll kms)

bronze marsh
#

Sooo i dont think it works😭

#

or maybe i did soemthing worng

tepid sigil
#

bruh

bronze marsh
#

leme check

tepid sigil
#

uhh

#

any error?

bronze marsh
#

not from what i see crouching just dosent seem to work

tepid sigil
#

hmm

bronze marsh
#

whenever i try to crouch it starts a slide but puts me right back up

tepid sigil
#

can you show a clip

#

what about sprinting/sliding?

bronze marsh
#

that works

#

but allso whenever i stand still and try to crouch im not able to move

tepid sigil
#

alright we can fix the crouching just show me a clip so i understand whats the issue

bronze marsh
bronze marsh
#

sorry i gotat relaunch medal for me to take a clip

tepid sigil
#

np

bronze marsh
#

wait leme insert the animations again that may be why

tepid sigil
#

you can spoof

bronze marsh
#

ima check that rq and see if that fixes it

#

ill send a clip if that dosent chaneg anything

tepid sigil
#

alright

bronze marsh
#

dose this help?

#

so

#

frist part is me trying crouch then walk

#

second part is me trying walk the crouch

#

allso whenever i slide

#

it adds my run animation into it top

#

allso whenever i dont hit ctrl while slideing it forces me into a stiff pose

#

SORRY IM VERY THANKFULL FOR ALL THE HELP

#

I DONT WANA SOUND LIKE A BITCH COMPLAING

#

😭

#

@tepid sigil

#

ALLSO YOU DONT HAVE TO FIX IT

tepid sigil
#

lemme finish my game and ill take a look

bronze marsh
#

OKOK

tepid sigil
#

also

#

switch to dark mode

#

or we're gonna have a war

bronze marsh
#

HOW

tepid sigil
#

studio settings

bronze marsh
#

wheree

tepid sigil
#

oookay let me

bronze marsh
#

whoops

tepid sigil
#

get to the typing

bronze marsh
#

well

#

did you see that

tepid sigil
#

yes

#

i have msg log

bronze marsh
#

OH

#

i didnt wana over whelm you or something

tepid sigil
#

nah bro ima try

#

@bronze marsh is it okay if i separate walking and idle crouch

#

cuz that way it'll use anims properly

#

you'll just have to make or find a crouch walk animation

#

silence means yes

#

amazing

bronze marsh
#

YEA

#

SORRY

#

I WAS PLAYING ROBLOX

tepid sigil
#

sprint

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)
local isSprinting = false
local sprintAnim

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift and not _G.isCrouching then
        isSprinting = true
        _G.isSprinting = true
        Humanoid.WalkSpeed = 26

        if not sprintAnim then
            sprintAnim = Instance.new("Animation")
            sprintAnim.AnimationId = "rbxassetid://9040323497"
        end

        local playAnim = Animator:LoadAnimation(sprintAnim)
        playAnim:Play()
    end
end)

UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSprinting = false
        _G.isSprinting = false
        Humanoid.WalkSpeed = _G.isCrouching and 8 or 16

        for _, anim in pairs(Animator:GetPlayingAnimationTracks()) do
            anim:Stop()
        end
    end
end)```
# crouch with walk and idle bozo
```lua
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local char = script.Parent
local Humanoid = char:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)

local isCrouching = false
local crouchIdleAnim
local crouchWalkAnim
local playingCrouchAnim

UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed or _G.isSprinting then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        isCrouching = not isCrouching
        _G.isCrouching = isCrouching
        Humanoid.WalkSpeed = isCrouching and 8 or 16

        if not crouchIdleAnim then
            crouchIdleAnim = Instance.new("Animation")
            crouchIdleAnim.AnimationId = "rbxassetid://YO_CROUCH_IDLE_NUDES" -- yes bozo put it here
        end
        if not crouchWalkAnim then
            crouchWalkAnim = Instance.new("Animation")
            crouchWalkAnim.AnimationId = "rbxassetid://YO_CROUCH_WALK_ANIMATION" -- yes bozo put it here
        end

        if playingCrouchAnim then
            playingCrouchAnim:Stop()
        end
        playingCrouchAnim = Animator:LoadAnimation(crouchIdleAnim)
        playingCrouchAnim:Play()
    end
end)

RunService.RenderStepped:Connect(function()
    if isCrouching then
        local velocity = Humanoid.MoveDirection.Magnitude
        if velocity > 0 then
            if playingCrouchAnim then playingCrouchAnim:Stop() end
            playingCrouchAnim = Animator:LoadAnimation(crouchWalkAnim)
            playingCrouchAnim:Play()
        else
            if playingCrouchAnim then playingCrouchAnim:Stop() end
            playingCrouchAnim = Animator:LoadAnimation(crouchIdleAnim)
            playingCrouchAnim:Play()
        end
    end
end)```
#

slide into yo booty rizz

local UIS = game:GetService("UserInputService")
local char = script.Parent
local Humanoid = char:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)
local canSlide = true
local slideAnim

UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed or not _G.isSprinting or not canSlide then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        canSlide = false
        _G.isSprinting = false
        Humanoid.WalkSpeed = 10

        if not slideAnim then
            slideAnim = Instance.new("Animation")
            slideAnim.AnimationId = "rbxassetid://139682445589811"
        end

        local playAnim = Animator:LoadAnimation(slideAnim)
        playAnim:Play()

        local slide = Instance.new("BodyVelocity")
        slide.MaxForce = Vector3.new(1,0,1) * 30000
        slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
        slide.Parent = char.HumanoidRootPart

        for count = 1, 8 do
            wait(0.1)
            slide.Velocity *= 0.7
        end

        playAnim:Stop()
        slide:Destroy()
        Humanoid.WalkSpeed = 16
        _G.isSprinting = false
        canSlide = true
    end
end)```
#

i'm lazy to explain

#

just try

#

don't forget to put crouch animations

bronze marsh
#

OK OK LEME LAUNCH STUDIO

#

we;;

#

well

#

crouching is bugged again

#

i think

#

it works betetr then last time

#

here if you wnat too try again if not i get that but like

#

here if you do hop in vc

#

ill screen share

tepid sigil
#

crouch

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local char = script.Parent
local Humanoid = char:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)

local isCrouching = false
local crouchIdleAnim
local crouchWalkAnim
local playingCrouchAnim

UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed or _G.isSprinting then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        isCrouching = not isCrouching
        _G.isCrouching = isCrouching
        Humanoid.WalkSpeed = isCrouching and 8 or 16

        if not crouchIdleAnim then
            crouchIdleAnim = Instance.new("Animation")
            crouchIdleAnim.AnimationId = "rbxassetid://idle"
        end
        if not crouchWalkAnim then
            crouchWalkAnim = Instance.new("Animation")
            crouchWalkAnim.AnimationId = "rbxassetid://walk"
        end

        if playingCrouchAnim then
            playingCrouchAnim:Stop()
        end

        playingCrouchAnim = Animator:LoadAnimation(crouchIdleAnim)
        playingCrouchAnim:Play()
    end
end)

RunService.RenderStepped:Connect(function()
    if isCrouching then
        local velocity = Humanoid.MoveDirection.Magnitude

        if velocity > 0 and playingCrouchAnim ~= crouchWalkAnim then
            if playingCrouchAnim then playingCrouchAnim:Stop() end
            playingCrouchAnim = Animator:LoadAnimation(crouchWalkAnim)
            playingCrouchAnim:Play()
        elseif velocity == 0 and playingCrouchAnim ~= crouchIdleAnim then
            if playingCrouchAnim then playingCrouchAnim:Stop() end
            playingCrouchAnim = Animator:LoadAnimation(crouchIdleAnim)
            playingCrouchAnim:Play()
        end
    end
end)```

# slide
```lua
local UIS = game:GetService("UserInputService")
local char = script.Parent
local Humanoid = char:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)
local canSlide = true
local slideAnim
local slidePlaying = false

UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed or not _G.isSprinting or not canSlide then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        canSlide = false
        _G.isSprinting = false
        Humanoid.WalkSpeed = 10
        slidePlaying = true

        if not slideAnim then
            slideAnim = Instance.new("Animation")
            slideAnim.AnimationId = "rbxassetid://139682445589811"
        end

        for _, anim in pairs(Animator:GetPlayingAnimationTracks()) do
            anim:Stop()
        end

        local playAnim = Animator:LoadAnimation(slideAnim)
        playAnim:Play()

        local slide = Instance.new("BodyVelocity")
        slide.MaxForce = Vector3.new(1,0,1) * 30000
        slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
        slide.Parent = char.HumanoidRootPart

        for count = 1, 8 do
            wait(0.1)
            slide.Velocity *= 0.7
        end

        playAnim:Stop()
        slide:Destroy()
        Humanoid.WalkSpeed = 16
        _G.isSprinting = false
        canSlide = true
        slidePlaying = false
    end
end)```
#

sprint

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)
local isSprinting = false
local sprintAnim

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift and not _G.isCrouching and not _G.slidePlaying then
        isSprinting = true
        _G.isSprinting = true
        Humanoid.WalkSpeed = 26

        if not sprintAnim then
            sprintAnim = Instance.new("Animation")
            sprintAnim.AnimationId = "rbxassetid://9040323497"
        end

        for _, anim in pairs(Animator:GetPlayingAnimationTracks()) do
            anim:Stop()
        end

        local playAnim = Animator:LoadAnimation(sprintAnim)
        playAnim:Play()
    end
end)

UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSprinting = false
        _G.isSprinting = false
        Humanoid.WalkSpeed = _G.isCrouching and 8 or 16

        for _, anim in pairs(Animator:GetPlayingAnimationTracks()) do
            anim:Stop()
        end
    end
end)```
#

add " at the end

#

forgot what its called

#

@bronze marsh

#

i'll send the plugin here and an asset here

#

asset in dms*

#

hold on