hello guys so im loading an animation from a module script, but the third animation does not play, and instead i get the error “LoadAnimation requires an Animation Object”, assuming this error means that the 3rd animation is nil
function handler:M1_Client()
local character = game.Players.LocalPlayer.Character
local weapon = character:FindFirstChild("Loadout"):WaitForChild("Weapon")
local name = handler:get_name(weapon)
local blade = weapon:FindFirstChild("Blade")
self.clean = trove.new()
local c = 0
uis.InputBegan:Connect(function(input, gpe)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not gpe then
if is_equipped == true and state_debounce == false then
state_debounce = true
c += 1
if c == 3 then
c = 0
end
character:FindFirstChild("Humanoid"):LoadAnimation(animations.Katana[c]):Play()
task.wait(0.8)
state_debounce = false
end
end
end)
end
idk why the animation in the 3rd index is not playing
plz help
instead of findfirstchild you need to wait for the child.
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Track = Animator:LoadAnimation(animations.Katana[c])
Track:Play()
The error you’re getting “LoadAnimation requires an Animation Object” is the game trying to tell you that youre trying to run LoadAnimation on a nil (non existant) object. This means that you need to wait until the object exists before you can continue.
There could be many issues with your script however, there’s a lot of code and you will probably need to do more scanning to see what kind of typos or errors you didn’t notice.
You should instead try something along the lines of this, i’ve made combo chains before and I think maybe you should give it a try:
local ComboNum = 1
local MaxClicks = 3
local TimeSinceLastClick
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Animations = {
["Katana"] = {
game.ReplicatedStorage.AnimationsFolder.Katana.Animation1,
game.ReplicatedStorage.AnimationsFolder.Katana.Animation2,
game.ReplicatedStorage.AnimationsFolder.Katana.Animation3,
};
}
local function playAnimation()
local Animation = Animations["Katana"][ComboNum]
local Track = Animator:LoadAnimation(Animation)
Track:Play()
end
local function clicked()
playAnimation()
if (ComboNum + 1 > MaxClicks) or (TimeSinceLastClick and tick() > TimeSinceLastClick + .8) then
ComboNum = 1
else
ComboNum += 1
end
TimeSinceLastClick = tick()
end
The main issue you’re having is that your combo has a 0 value that is possible to be indexed. It’s likely a bug, so maybe you could try setting it to 1 instead of 0 and alternatively making it so it adds to the combo after playing the animation.
This script will not work it’s just a demonstration on how you can do things