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

Animation for sword not working? - HELP!

Asked by 9 years ago

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

01local animation = Instance.new("Animation")
03local player = script.Parent.Parent
04--local animTrack = player.Humanoid:LoadAnimation(animation)
05local tool = script.Parent
06 
07tool.Equipped:connect(function(Mouse)
08 
09Mouse.Button1Down:connect(function()
10 
11print("Slash"
12    local animTrack = player.Humanoid:LoadAnimation(animation).animTrack:Play()
13    --animTrack:Play()     
14 
15    end)
16end)

Thank you!

1 answer

Log in to vote
1
Answered by 9 years ago
01local animation = Instance.new("Animation")
02animation.AnimationId = "http://www.roblox.com/asset/?id=271296707" --Changed this into an AssetID
03local player = script.Parent.Parent
04--local animTrack = player.Humanoid.Animator:LoadAnimation(animation)
05local tool = script.Parent
06 
07tool.Equipped:connect(function(Mouse)
08 
09Mouse.Button1Down:connect(function()
10 
11print("Slash"
12    local animTrack = player.Humanoid.Animator:LoadAnimation(animation) -- I changed this to Animator. I did this before, and I found doing this easier.
13    animTrack:Play()     
14    end)
15end)
0
Okay, I'll try. DeDeaD564 15 — 9y
0
When you say Asset ID do you mean the number? DeDeaD564 15 — 9y
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. xPolarium 1388 — 9y
0
Agh got that but now it says Humanoid is not a valid member of Backpack Any idea? DeDeaD564 15 — 9y
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! DeDeaD564 15 — 9y
Ad

Answer this question