I’m trying to create a script that plays a different variation of the “Run Animation” based on the direction the player is going in the first person
local hum = script.Parent:WaitForChild(“Humanoid”)
local uis = game:GetService(“UserInputService”)
local front = hum:LoadAnimation(script:WaitForChild(“Front”))
local back = hum:LoadAnimation(script:WaitForChild(“Back”))
local left = hum:LoadAnimation(script:WaitForChild(“Left”))
local right = hum:LoadAnimation(script:WaitForChild(“Right”))
uis.InputBegan:Connect(function(key)
if hum.FloorMaterial ~= Enum.Material.Air and script.Parent.Value.Crouch.Value == false then
if key.KeyCode == Enum.KeyCode.W then
front:Play()
script.Front.Value.Value = true
elseif key.KeyCode == Enum.KeyCode.S then
back:Play()
script.Back.Value.Value = true
elseif key.KeyCode == Enum.KeyCode.D then
right:Play()
script.Right.Value.Value = true
elseif key.KeyCode == Enum.KeyCode.A then
left:Play()
script.Left.Value.Value = true
end
else
front:Stop()
back:Stop()
right:Stop()
left:Stop()
end
end)
uis.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.W then
front:Stop()
script.Front.Value.Value = false
elseif key.KeyCode == Enum.KeyCode.S then
back:Stop()
script.Back.Value.Value = false
elseif key.KeyCode == Enum.KeyCode.D then
right:Stop()
script.Right.Value.Value = false
elseif key.KeyCode == Enum.KeyCode.A then
left:Stop()
script.Left.Value.Value = false
end
end)
hum:GetPropertyChangedSignal(“FloorMaterial”):Connect(function()
if hum.FloorMaterial == Enum.Material.Air then
front:Stop()
back:Stop()
right:Stop()
left:Stop()
repeat wait()
until hum.FloorMaterial ~= Enum.Material.Air
if script.Front.Value.Value == true then
front:Play()
elseif script.Back.Value.Value == true then
back:Play()
elseif script.Left.Value.Value == true then
left:Play()
elseif script.Right.Value.Value == true then
right:Play()
end
end
end)
The issue is that the animation suddenly stops along with all the other animations unrelated to the script. In the output, it spits out the error “AnimationTrack limit of 256 tracks for one Animator exceeded, new animations will not be played. (x36)”