Hi!
In this topic I will show you how to make sliding system and cooldown for it.
Result:
robloxapp-20220309-1435102.wmv (450.7 KB)
-
The first thing to do is to create a LocalScript in StarterCharacterScripts.
-
Then paste this script:
local UIS = game:GetService("UserInputService")
local char = script.Parent
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://YourID"
local keybind = Enum.KeyCode.Q
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 = false
==
playAnim:Stop()
slide:Destroy()
wait(15)
canslide = true
end
end)
Where it says “YourID” you need to insert your animation ID.
slideAnim.AnimationId = “rbxassetid://YourID”
-
Create a dummy and open the Animation Editor.
Make a pose and set “Action” in Set Animation Priority.
-
Next, save the animation and go to our animation page, copy the ID and paste it into the script.
-
To configure cooldown, we need to change one digit at the end of our script.
Find the last 4 lines and find wait(15). Change the number to your own and you’re done!
playAnim:Stop()
slide:Destroy()
wait(15)
canslide = true
end
end)
- Here we can change the letter to which the ability will be used.
local keybind = Enum.KeyCode.Q