I have an issue with my animation LocalScript that is meant to control the moving and idle crawl animation.
ENABLED = nil
MOVING = false
CRAWL_KEY = Enum.KeyCode.C
-- move: 6579821142
-- idle: 6579822187
local GenInput = game:GetService("UserInputService")
local GenChar = script.Parent
local GenHumanoid = GenChar:WaitForChild("Humanoid")
local MoveAnimation = script:WaitForChild("crawl_move")
local IdleAnimation = script:WaitForChild("crawl_move")
local LoadMoveAnim = GenHumanoid:LoadAnimation(MoveAnimation)
local LoadIdleAnim = GenHumanoid:LoadAnimation(MoveAnimation)
GenInput.InputBegan:Connect(function(GenInput)
if GenInput.KeyCode == CRAWL_KEY and ENABLED == false then
LoadIdleAnim:Play()
ENABLED = true
else
if ENABLED == true and (GenInput.KeyCode == CRAWL_KEY) then
LoadIdleAnim:Stop()
ENABLED = false
end
end
if GenInput.KeyCode == Enum.KeyCode.A or GenInput.KeyCode == Enum.KeyCode.D and ENABLED == true then
LoadMoveAnim:Play()
MOVING = true
ENABLED = true
else
if GenInput.KeyCode == Enum.KeyCode.A or GenInput.KeyCode == Enum.KeyCode.D and ENABLED == false then
LoadMoveAnim:Stop()
MOVING = false
--ENABLED = false
end
end
end)
When I move to the right (D key) it moved as expected, but when I move to the left (A key) it always runs the crawl animation without me pressing C, and it continues like this until I press C and move to the right, then it happens again when I go left, etc.