Why does this script work when I test it solo in studio, but when I play the game, it doesn't work? I have to drop the weapon and then pick it up to make it work. Can someone fix this please so you don't have to drop it to fix it?
local animation = Instance.new('Animation') local animTrack local debounce = false local player = game.Players.LocalPlayer.Character function onEquip() script.Parent.Handle.UnsheathSound:Play() end function onActivate() if not debounce then debounce = true if player:FindFirstChild('ForceField') then player.ForceField:Destroy() end animation.AnimationId = "http://www.roblox.com/asset/?id=129967390" animTrack = player.Humanoid:LoadAnimation(animation) animTrack:Play() script.Parent.Handle.SlashSound:Play() script.Parent.Handle.Script.Disabled = false wait(0.5) animTrack:Stop() script.Parent.Handle.Script.Disabled = true wait(0.5) debounce = false end end function onUnequip() animTrack:Stop() end script.Parent.Equipped:connect(onEquip) script.Parent.Unequipped:connect(onUnequip) script.Parent.Activated:connect(onActivate)