Animate on mouse hover

Hi there,
I’m currently trying to make an NPC wave when the player is hovering their mouse over them. Currently no errors in output, but no result either.

Code is from a LocalScript in StartPlayerScripts.

local NPC = game.Workspace:WaitForChild("NPCs"):WaitForChild("NPC1")
local Humanoid = NPC:FindFirstChildOfClass("Humanoid")
local ClickDetector = NPC:WaitForChild("Hitbox"):WaitForChild("ClickDetector")

local waveAnimId = "rbxassetid://507770239"
local waveAnimation = Instance.new("Animation")
waveAnimation.AnimationId = waveAnimId

local playingTrack

ClickDetector.MouseHoverEnter:Connect(function()
	if not playingTrack then
		playingTrack = Humanoid:LoadAnimation(waveAnimation)
		playingTrack:Play()
	end
end)

ClickDetector.MouseHoverLeave:Connect(function()
	if playingTrack then
		playingTrack:Stop()
		playingTrack = nil
	end
end)

Any help is greatly appreciated.

Andddd, this is a LocalScript, right? These functions only work on them.

Yes, a LocalScript in StarterPlayerScripts. Is this the right way to go about this one?

Yup. Though, Humanoid:LoadAnimation is deprecated, but I don’t think it’ll cause any issue here.

I’d go through this checklist to eliminate all possible issues:

In the linked post you mention that you need to be the owner of the animation - does this still apply to default Roblox animations?