Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Animation for sword not working? - HELP!

I'm trying to make a sword with its one custom animation when slashing, so far I have made the animation work without the sword instead pressing r plays the animation BUT I can't figure out how to fix this issue, so far no error pop ups are confirmed but the animation doesn't play. I need someone to explain to me what happened, not just short sentence answers.

Here's the script

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Slash-Test-item?id=271296707"
local player = script.Parent.Parent
--local animTrack = player.Humanoid:LoadAnimation(animation)
local tool = script.Parent

tool.Equipped:connect(function(Mouse)

Mouse.Button1Down:connect(function()

print("Slash")	
	local animTrack = player.Humanoid:LoadAnimation(animation).animTrack:Play()
	--animTrack:Play()		

    end)
end)

Thank you!

1 answer

✓ Accepted answer
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=271296707" --Changed this into an AssetID
local player = script.Parent.Parent
--local animTrack = player.Humanoid.Animator:LoadAnimation(animation)
local tool = script.Parent

tool.Equipped:connect(function(Mouse)

Mouse.Button1Down:connect(function()

print("Slash")  
    local animTrack = player.Humanoid.Animator:LoadAnimation(animation) -- I changed this to Animator. I did this before, and I found doing this easier.
    animTrack:Play()      
    end)
end)

5 comments

0

Okay, I'll try.

0

When you say Asset ID do you mean the number?

0

He means, for the base URL of the AnimationID, you should keep it as "/asset/?id=NUMBERSHERE" instead of using the URL given in Roblox Catalog or whatever.

0

Agh got that but now it says Humanoid is not a valid member of Backpack Any idea?

0

Found the mistake, the player variable was in backpack so I just removed one parent then added it after local animTrack = player.Parent. Anyway thanks for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.