So, I've been working on this script for a short while now, and with the help of another SH member, I've been able to get it working.
lscript = script.Parent:WaitForChild("LocalScript")
animation = lscript:WaitForChild("ShunStart")
animation1 = lscript:WaitForChild("Salute")
animation2 = lscript:WaitForChild("RightDress")
animation3 = lscript:WaitForChild("AtEaseLoop")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local animation = script.ShunStart
local animation1 = script.Salute
local animation2 = script.RightDress
local animation3 = script.AtEaseLoop
local animTrack = nil
script.Parent.Selected:connect(function()
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 issue I seem to have is that, I tried to make it so that these animations would only play when the tool is selected, and that they'd stop being played once the tool is deselected.
So, for example; when the tool is selected, the animations will play when a key is pressed, but when the tool is not selected, the animations will not play when the keys are pressed.
It seems all that deselecting the tool does is stop the animations, which, whilst this is helpful, this really isn't what I wish to happen.
Again, help is much appreciated.

2 comments
To elaborate further, this is a localscript within a hopperbin. The issue I'm having is that when the tool is deselecting, the keys still trigger the animations. I wish to make it so that when the hopperbin is deselected, pressing the keys will not trigger the animations.
Use regular tool objects, hopperbins are very outdated, and ROBLOX doesn't recommend use of them anymore.