Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make it so that the tool doesn't play the animation upon equipping it?

Asked by 8 years ago

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)

1 answer

Log in to vote
0
Answered by
XAXA 1569 Moderation Voter
8 years ago

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)

Ad

Answer this question