So you see, I have a sword that plays a custom animation whenever you click the mouse button.
But the problem i'm having is that it also plays the animation upon equipping the sword. How do I fix this?
local tool = script.Parent local function onEquip() end local function onUnequip() end local function onActivate() local Humanoid = game.Players.LocalPlayer.Character.Humanoid local anim=Instance.new("Animation") anim.Name = "Drawanim" anim.AnimationId = 'http://www.roblox.com/asset/?id=348140986' anim.Parent = workspace script.Parent.Equipped:connect(function (idk) local playanim = Humanoid:LoadAnimation(anim) playanim:Play() end) end local function onDeactivate() end tool.Equipped:connect(onEquip) tool.Unequipped:connect(onUnequip) tool.Activated:connect(onActivate) tool.Deactivated:connect(onDeactivate)
Just omit the Equipped event on line 18
. The Equipped event triggers every time the player equips a tool.
It should look like this:
local tool = script.Parent local function onEquip() end local function onUnequip() end local function onActivate() local Humanoid = game.Players.LocalPlayer.Character.Humanoid local anim=Instance.new("Animation") anim.Name = "Drawanim" anim.AnimationId = 'http://www.roblox.com/asset/?id=348140986' anim.Parent = workspace --[[ script.Parent.Equipped:connect(function (idk) local playanim = Humanoid:LoadAnimation(anim) playanim:Play() end) ]] --remove me end local function onDeactivate() end tool.Equipped:connect(onEquip) tool.Unequipped:connect(onUnequip) tool.Activated:connect(onActivate) tool.Deactivated:connect(onDeactivate)