So, I've created an animation tool in which activates once the hopperbin tool is selected. It runs fine in Studio, but once in-game I get the error "Animation is not a valid member of LocalScript" in the developer console. All of the animations are saved inside the script, and I don't think I've done anything wrong? Could just be a small mistake.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
animation = script.Parent.LocalScript.ShunStart
animation1 = script.Parent.LocalScript.Salute
animation2 = script.Parent.LocalScript.RightDress
animation3 = script.Parent.LocalScript.AtEaseLoop
animTrack = nil
script.Parent.Selected:connect(function(Player)
Mouse.KeyDown:connect(function(key)
if key == "q" then
for _,v in pairs(Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()) do v:Stop(0) end
animTrack = Player.Character:FindFirstChild("Humanoid"):LoadAnimation(animation)
animTrack:Play()
end
end)
Mouse.KeyDown:connect(function(key)
if key == "r" then
for _,v in pairs(Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()) do v:Stop(0) end
animTrack = Player.Character:FindFirstChild("Humanoid"):LoadAnimation(animation2)
animTrack:Play()
end
end)
Mouse.KeyDown:connect(function(key)
if key == "t" then
for _,v in pairs(Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()) do v:Stop(0) end
animTrack = Player.Character:FindFirstChild("Humanoid"):LoadAnimation(animation3)
animTrack:Play()
end
end)
Mouse.KeyDown:connect(function(key)
if key == "e" then
for _,v in pairs(Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()) do v:Stop(0) end
animTrack = Player.Character:FindFirstChild("Humanoid"):LoadAnimation(animation1)
animTrack:Play()
wait(3)
animTrack:Stop()
animTrack = Player.Character:FindFirstChild("Humanoid"):LoadAnimation(animation)
animTrack:Play()
end
end)
Mouse.KeyDown:connect(function(key)
local Key = key:lower()
if Key == "p" then
for _,v in pairs(Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()) do v:Stop(0) end
end
end)
script.Parent.Deselected:connect(function()
for _,v in pairs(Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()) do v:Stop(0) return end
end)
end)
The tool's structure is:
Hopperbin
LocalScript
Animations
Any help on the matter is appreciated, but I just can't seem to get it working in-game.

2 comments
Instead of individual functions, why not have one and just use an elseif?
This isn't the issue, I understand I'm a bit of a sloppy scripter. It works perfectly in studio, however in-game it states that the animations in LocalScript aren't a valid member of LocalScript.