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

Sword Script Will Not Animate When Running The Animate Function?

Asked by
LuaDLL 253 Moderation Voter
5 years ago

Is there something i'm doing wrong?

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

local Tool = script.Parent

local Equipped = false

--/ Animation Controler
local CurrentAnim = nil
local Animation = nil

local Animations = {
    Swing = "http://www.roblox.com/asset/?id=2560427208",
}

function animate(Key)
    if Animations[Key] then
        Animation = Instance.new("Animation")
        Animation.AnimationId = Animations[Key]
        local AnimTrack = Character.Humanoid:LoadAnimation(Animation)
        AnimTrack:Play()
        CurrentAnim = AnimTrack
        AnimTrack.Stopped:Connect(function()
            CurrentAnim = nil
            AnimTrack:Destroy()
            Animation = nil
        end)
    end
end

--/ Functions
Tool.Equipped:Connect(function()
    print("Equipped "..Tool.Name)
    Equipped = true
end)

Tool.Unequipped:Connect(function()
    print("Unequipped "..Tool.Name)
    Equipped = false
end)

Tool.Activated:Connect(function()
    print("Activated "..Tool.Name)
    if Equipped then
        animate("Swing")
        print("Animated")
    end
end)

It doesn't print Any Errors.

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Make sure your animation level is "Action", action is the most prioritized animations and will play over movement, idle, and core.

The levels go as such...

Action -- Highest

Movement

Idle

Core -- Lowest

Go to the priority section of this page

0
Thank you! It works perfectly now, did not know about that xd LuaDLL 253 — 5y
Ad

Answer this question