Hi, this script works fine, but here's a problem when i equip it, then unequip it, it shows a error in the console
script below: enabled = false
local Tool = script.Parent;
local player = game.Players.LocalPlayer
function onActivated()
--This will check if it is enabled and then either start dancing or stop dancing
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
player.Character.Humanoid.JumpPower = 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
player.Character.Humanoid.JumpPower = 50
end
end
function onUnequipped()
it happens here somewhere
player.Character.Humanoid.JumpPower = 50
dancer:Stop()
dancer:remove()
Tool.dancepart.SongLoop:Stop()
enabled = false
player.Character.Humanoid.WalkSpeed = speed
end
Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)
please help.
this is my first post.