Hello, this emote tool works fine but here's a problem, when i equip it then unequip it, it makes a error in the console
it says: dancer = index nil value or something
code below:
enabled = false
local Tool = script.Parent;
local dancer = nil
local player = game.Players.LocalPlayer function onActivated() if enabled == false then local humanoid = Tool.Parent:FindFirstChild("Humanoid") local torso = Tool.Parent:FindFirstChild("Torso") dancer = humanoid:LoadAnimation(Tool.dance) Tool.DanceObject.Value = dancer dancer:Play() Tool.dancepart.Position = player.Character.Head.Position Tool.dancepart.SongLoop:Play() enabled = true speed = player.Character.Humanoid.WalkSpeed player.Character.Humanoid.WalkSpeed = 0 repeat wait(1) Tool.dancepart.Position = player.Character.Head.Position until enabled == false else dancer:Stop() dancer:remove() Tool.dancepart.SongLoop:Stop() enabled = false player.Character.Humanoid.WalkSpeed = speed end end function onUnequipped() dancer:Stop() dancer:remove() Tool.dancepart.SongLoop:Stop() enabled = false player.Character.Humanoid.WalkSpeed = speed end Tool.Activated:connect(onActivated) Tool.Unequipped:connect(onUnequipped)
thank you.