Viewport NPC does not play animation

yea im trying to make a dance menu but for some reason the NPC doesnt play the animation when i hover over the button when its suppose to.

I have tried making the animation as a new instance and placing in the NPC but doesnt work.

image

local DancePreviewCharacter = script.Parent.Parent.Parent.DancePreview.ViewportFrame.R6
local button = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character

repeat wait()
character = player.Character
until character

local dance = character.Humanoid:LoadAnimation(script.Parent.Animation)
local previewanimation = script.Parent.Animation:Clone()
previewanimation.Parent = DancePreviewCharacter

local previewdance = DancePreviewCharacter.Humanoid:LoadAnimation(previewanimation)

local isDancing = false

button.MouseButton1Click:Connect(function()
if isDancing == false then
dance:Play()
isDancing = true
else
dance:Stop()
isDancing = false
end
end)

button.MouseEnter:Connect(function()
print(“press played”)
previewdance:Play()
end)

button.MouseLeave:Connect(function()
previewdance:Stop()
end)

1 Like