I'm not on why it's not playing the animation when the user selects the tool. Please help?

local human = game.Players.LocalPlayer.Character:WaitForChild('Humanoid')
local danceanim = human:LoadAnimation(script.dance)
dancing = false

function onSelected()
if dancing == false then
dancing = true
danceanim:Play()
end
end

function unSelected()
if dancing == true then
dancing = false
danceanim:Stop()
end
end

script.Parent.Selected:connect(onSelected)
script.Parent.Deselected:connect(unSelected)