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)