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

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

Log in to vote
1
Answered by 9 years ago
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)

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