When the player move's if I press the key to activate the animation it doesn't apply, how do i fix this problem?
local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService('UserInputService')
local AnimationId = 'rbxassetid://0'
local Key_Charge = 'Q'
local Toggle = true
Mouse.KeyDown:connect(function(key)
key = string.lower(key)
if string.byte(key) == 113 then
Toggle = true
local keyConnection = Mouse.KeyUp:connect(function(key)
if string.byte(key) == 113 then
Toggle = false
end
end)
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationId
local LoadAnimation = Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
repeat wait () until Toggle == false
keyConnection:disconnect()
Animation:Destroy()
end
end)

1 comment
Use InputBegan instead of KeyDown, and indent your code