#Animation for sword

1 messages · Page 1 of 1 (latest)

half hornet
#

I dont know why this doesnt work can someone explain me how to fix it ?

local tool = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://106833537814736"


local debounce = false

tool.Activated:Connect(function()
    if debounce == false then
        debounce = true

        tool.Parent:FindFirstChild("Humanoid").Animator:LoadAnimation(animation):Play()

        wait(3)

        debounce = false
    end
end)
main swallow
#

what r u tryna do

half hornet
#

when i pick sword the character do aniamation

main swallow
#

Uh

#

Pick it up?

#

Or equip it

half hornet
#

I mean equip

#

mb

main swallow
#

You haven’t checked if it was equipped anywhere from what I see

half hornet
#

so I must change the tool.Activated to tool.Equipped?

main swallow
#

here

#
local tool = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://106833537814736" -- make sure this is the correct id


local debounce = false

tool.Equipped:Connect(function()
  print("Tool was equipped")
    if debounce == false then
        debounce = true
                
          tool.Parent:FindFirstChild("Humanoid").Animator:LoadAnimation(animation):Play()
                  print("Animation was played")
        wait(3)

        debounce = false
    end
end)
#

@half hornet

main swallow
#

Use print statements in the future to see where your script breaks as well

half hornet
#

thx I know what I must change rn

main swallow
#

also task.wait() is better than wait() though it dont matter on smaller scripts

main swallow