You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Make a module script for a sword
What is the issue? Include screenshots / videos if possible!
In the module script I reference the tool and try and find humanoid by finding the first child of tool.Parent.Parent! also when I load the animation it says attempt to index nil with LoadAnimation Sword_Module (DelphinusTheDev Editing) - Roblox Studio 7_30_2021 1_56_55 PM|690x356
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried debugging the script and adding prints like if humanoid then print(“Humanoid”) else print(“None”). None got printed out. I even tried changing tool.Parent.Parent to just tool.Parent
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
I’m not sure how to deal with humanoids in modulescripts but I have a solution in mind, I’ll describe it soon. Also, humanoid:LoadAnimation is deprecated, use humanoid.Animator:LoadAnimation
Maybe you could use a load the animations when a player calls swing(), keep the player and the animationtrack created in a dictionary like this:
local loadedanims = {
player1.Character = animationtrack
}
initially it wont look like the one i’ve put but it gives an idea of what to put in the table
when swing() is called, check if the player isnt in the table then get their humanoid/animator and load the animation, and call :Play() when needed, though you may need to put the player as a parameter in the swing() function to check whether the player is in the table. This is how I would do it
But I would need to load the animation in the humanoid and for some reason when I do character:FindFirstChild(“Humanoid”) the Humanoid isn’t found?
Your use of the MoudleScript completely defeats why they exist, but your .swing() function is tyring to use hit which isn’t listed in your function’s parameters.
Apologies, didn’t see the nested Touch Function, but for using a ModuleScript like this would defeat the purpose as this ModuleScript will be copied into each tool, so each tool would have it’s own ModuleScript… So nothing would be shared.
If I put it in server storage and then required the module in every sword would I be able to make the damage and other variables different but not change the other swords variables. Also do you know the solution to my problem?