Need help on making a Boss Attack Module & Animation work

Introduction

Hello I just got back into trying to script again and have been getting more into Module Scripts, I need help with trying to make a Attack Function for my small dummy boss with animation implemented, how I want it to work is for the function I put the name of the dummy boss, and the name of the attack I want it to do, then theres another function that looks for the name of that attack I named inside of the Animations folder, I keep getting an error and need help with it.

The Module ( Inside of The Script )

local Attacks = {}

function Attacks.PlayAnimation(Char, Animation)
	local Character = Char
	local HumanoidExists = Character:FindFirstChild("Humanoid") and Character:FindFirstChild("Animations")
	if HumanoidExists then
		local HumAnim = HumanoidExists:LoadAnimation(Character.Animations:FindFirstChild(Animation))
		HumAnim:Play()
	end
end

function Attacks.Attack(Char, Attack)
	local Character = Char
	local HumanoidExists = Character:FindFirstChild("Humanoid")
	if HumanoidExists then
		Attacks.PlayAnimation(Char, Attack)
	end
end

return Attacks

The Script ( Inside of the Dummy )

local AttacksModule = require(script.Attacks)
local Dummy = script.Parent

while true do
	AttacksModule.Attack(Dummy, "Stomp")
	wait(5)
end

Errors

LoadAnimation is not a valid member of Folder "Workspace.Starter-Dummy.Animations"

 Script 'Workspace.Starter-Dummy.Handler.Attacks', Line 7 - function PlayAnimation

Script 'Workspace.Starter-Dummy.Handler.Attacks', Line 16 - function Attack  -  Studio - Attacks

Any kind of help would greatly be appreciated.

Which one is “Load animation”?

[quote=“AutoGamerChadYT, post:1, topic:1929573”]
local HumAnim = HumanoidExists:LoadAnimation(Character.Animations:FindFirstChild(Animation))
[/quote] this, its suppose to load the animation to the humanoid or something, like a built in function or whatever it is. edit: bro why my quote no work, o well

I know the problem, ur not calling the function, it never knows when to execute

O thanks then, I’ma see what ways I can try to do to resolve this.

thank you so much man, I got it working now, I think it was because of a extra function I made that I didn’t need, i removed it, made the animation script and attack inside of one function and it works perfectly fine.

1 Like