local keybind = Enum.KeyCode.C
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(.1)
slide.Velocity *= .7
end
playAnim:Stop()
slide:Destroy()
canslide = true
end
end)
I was wondering if someone can add something to this. What I need is that the Player has to be holding down W+Shift and moving for the slide to work if I press W+Shift and not moving the animation won’t play
This would really help if someone could do this for me thanks
What you want to do is check if Shift is pressed. You can use UserInputService for this. Once you get a .InputBegan containing Shift you can store that is down. If it is down, then while pressing W you play the animation.
Since this requires that both W and Shift is held down it means the character will be moving, so you don’t need to make sure it is moving. What you need next is to register when Shift and W is let go, you can do this using .InputEnded.
He isn’t on right now But, I’ll give you the basics of the function you will have to write the script for the animations
local UIS = game:GetService("UserInputService") -- Here We are getting the UserInputService, This detects if the Player pressed a key such as W,S,D
UIS.InputBegan:Connect(function(Input) -- The Player pressed a Key
if Input.KeyCode == Enum.KeyCode.W and Enum.KeyCode.LeftShift then -- Here We check if the Key is W & Shift
-- The player has pressed/ is holding the W And leftShift key Do your Slide animation
end
end)
UIS.InputEnded:Connect(function(Input) -- The Player stopped holding/Pressing the key
if Input.KeyCode == Enum.KeyCode.W and Enum.KeyCode.LeftShift then -- We Check if the Keys are W & LeftShift
-- The Player stopped Holding W and the LeftShift key Stop the Slide animation
end
end)