What do you want to achieve? Keep it simple and clear!
The animation does not play when theres a 3 second cooldown.
What is the issue? Include screenshots / videos if possible!
The animation plays when theres a cooldown.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried making a topic, multiple web searches, and does not ever get close to fixing my problem.
local UIS = game:GetService("UserInputService")
local char = script.Parent
local playAnim
local keybind = Enum.KeyCode.E
local canslide = true
local debounce = 3
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end
if input.KeyCode == keybind and canslide then
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://9157679954"
canslide = false
playAnim = char.Humanoid:LoadAnimation(slideAnim)
playAnim.Priority = Enum.AnimationPriority.Action2
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()
wait(debounce)
canslide = true
end
end)
Probably dumb but, I can’t dash (Velocity not changing )and nothing changed, It’s still running in cooldown
-- Put "Slide Ability" in StarterPlayer and StarterCharacterScripts
-- Enjoy This Ability
local UIS = game:GetService("UserInputService")
local char = script.Parent
local humanoid = char:FindFirstChildOfClass("Humanoid")
local keybind = Enum.KeyCode.E
local canslide = true
local debounce = 3
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end
if input.KeyCode == keybind and canslide then
local animator = humanoid:FindFirstChildOfClass("Animator")
animator.AnimationId = "rbxassetid://9157679954"
canslide = false
local playAnim = humanoid:LoadAnimation(animator)
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()
wait(debounce)
canslide = true
end
end)
That’s not how you load an animation using the animator. Take a look closely at the example provided in the docs. You have to use the LoadAnimation method on the Animator not the Humanoid.
You tried to index AnimationID to Animator. Try this:
-- Put "Slide Ability" in StarterPlayer and StarterCharacterScripts
-- Enjoy This Ability
local UIS = game:GetService("UserInputService")
local char = script.Parent
local humanoid = char:FindFirstChildOfClass("Humanoid")
local keybind = Enum.KeyCode.E
local canslide = true
local debounce = 3
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end
if input.KeyCode == keybind and canslide then
local animator = humanoid:FindFirstChildOfClass("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://9157679954"
canslide = false
local playAnim = animator:LoadAnimation(animator)
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()
wait(debounce)
canslide = true
end
end)