So, I created this toggleable running animation. When I press the left control to toggle it, the animation plays over the idle and jumping animations. Consequently, it appears as if my character is running in place or running in the air. I need the idle animations to play when he is not moving and the jumping animations to play when he is jumping.
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://15595155448'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local char = player.Character
local hum = char.Humanoid
local running = false
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input, Chat)
if Input.KeyCode == Enum.KeyCode.LeftControl and not Chat and hum.Health >= 1 then
if running == false then
hum.WalkSpeed = 32
running = true
PlayAnim:Play()
elseif running == true then
hum.WalkSpeed = 16
running = false
PlayAnim:Stop()
end
end
end)
Please let me know if you see what is wrong.