Attempting to index nil while animating

I’m new to animation so I may be doing things wrong, but here’s the script:

local walkanimation = Instance.new("Animation")
local runanimation = Instance.new("Animation")
local fire1animation = Instance.new("Animation")
local fire2animation = Instance.new("Animation")
local aimfire1animation = Instance.new("Animation")
local aimfire2animation = Instance.new("Animation")

if idle == true then
	idleanimation.AnimationId = module.idleanimationid
	idleanimationtrack = animator:LoadAnimation(idleanimation)
	idleanimationtrack:Play()
else
	idleanimationtrack:Stop()
end

if walking == true then
	print("Walk")
	walkanimation.AnimationId = module.walkanimationid
	walkanimationtrack = animator:LoadAnimation(walkanimation)
	walkanimationtrack:Play()
else
	walkanimationtrack:Stop()
end

I declare the animator and the animation controller up the line.
The script will play the “idleanimation” fine, but not stop it. It won’t do anything with the “walkanimation” at all and returns "Attempt to index nil with ‘Play’.

Any help would be greatly appreciated.

Make sure that wherever you have the animationids stored, the names and animation ids are correctly spelled.