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

Humanoid:LoadAnimation(), the animation doesn't load?

Asked by 5 years ago
Edited 5 years ago

Hi, I want to make a knife but my animation doesn't load.. Why and how to fix?

This is in a ClientScript put in a Tool

--< Services
local PlayerService = game:GetService('Players')
local UserInputService = game:GetService('UserInputService')

--< Variables
local ToolS = script
local Tool = ToolS.Parent

local Player = PlayerService.LocalPlayer

local IsEquip = false
local LastAnim = {}

--< Functions
local function FindAnimation(player)
    for index, animation in pairs(Tool.Handle.Slashs:GetChildren()) do
        if LastAnim[1] ~= animation then
            LastAnim[1] = animation
            return animation, Tool.Handle.Sounds:GetChildren()[math.random(1, #Tool.Handle.Sounds:GetChildren())]
        end
    end
end

--< Events
Tool.Equipped:Connect(function()
    IsEquip = true
end)

Tool.Unequipped:Connect(function()
    IsEquip = false
end)

UserInputService.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 and IsEquip then
        local Anim, Sound = FindAnimation()
        if Anim then
            print(Anim.Name, Sound.Name)
            local AnimationTrack = Player.Character.Humanoid:LoadAnimation(Tool.Handle.Slashs[Anim.Name])
            AnimationTrack:Play()
            Sound:Play()
        end
    end
end)
0
Check the output for errors. You need to own the animation to use it. gullet 471 — 5y
0
It's my own animation, and the output is empty. NiniBlackJackQc 1562 — 5y

1 answer

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

Hi, I had the same problem but I got it fixed.

Who owns the game? You or a group? If it is you who owns the game, you must export the animation into YOUR profile. If it is a group that owns the game, the animation must be exported into THE GROUP. Roblox, for some reason, doesn't allow animations from another person in a game.

Ad

Answer this question