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

How do I play my Roblox Sword Animation?

Asked by 3 years ago

Hey I'm having a little bit of trouble playing my animation here is the code:

local SwordAnim = script.Parent:WaitForChild("SwordAnim")

script.Parent.Activated:Connect(function()
    SwordAnim:Play()
end)

I don't know if im forgetting something or what

1 answer

Log in to vote
0
Answered by
nlurn 15
3 years ago

You need to load the animation before you can play it. You will need to add this

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local SwordAnim = script.Parent:WaitForChild("SwordAnim")
local SwordTrack = Humanoid:LoadAnimation(SwordAnim)

script.Parent.Activated:Connect(function()
    SwordTrack:Play()
end)
0
It errored line 2 Kykysurvivin 20 — 3y
0
What did the error say? nlurn 15 — 3y
0
Also are you using a LocalScript or a server script? The error may be caused from not using a localscript nlurn 15 — 3y
Ad

Answer this question