So ,i have a script for my sword
local CanAttack = true
script.Parent.Equipped:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
idle:Play()
end)
script.Parent.Activated:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
if CanAttack == true then
attack:Play()
idle:Stop()
CanAttack = false
wait(1)
attack:Stop()
idle:Play()
CanAttack = true
script.Parent.canDamage.Value = true
end
end)
script.Parent.Unequipped:Connect(function()
local character = game.Players.LocalPlayer.Character
local idle = character.Humanoid:LoadAnimation(script.Idle)
idle:Stop()
end)
basically it plays the idle animation unless the tool is activated, then it will run the attack animation and go back to the idle animation after 1 second.
HOWEVER, the problem is.. when i unequipped the sword my character model still plays the idle animation, so he pretty much runs around with his hand up but no sword in it.

4 comments
awesome! this code worked! i do have a question though, what did making local idle = nil do? and also, what is the difference of having local in front of a variable name when creating it do?
http://wiki.roblox.com/index.php?title=Scope
hey can i ask why you made a local variable character at the bottom?
Actually, it doesn't need to be there. But if you want to access the character, put the variable at the top so you can use it across the whole script.