How to script a weapon in Roblox with multiple slash animations
Вставка
- Опубліковано 21 вер 2024
- Video Description:
Starting with a basic sword mesh, I guide you through creating captivating animations and combining them with powerful scripts to craft a fully functional great sword tool. Not only will you learn to script a multi-slash repeating combo, but this versatile method may be applied to various non-tool-based systems as well with just a few modifications. Join us and embark on a journey to master scripting a basic sword.
Fancy description stuff aside, this video took me ~6 hours over the course of several weeks to edit. The original recording was about 70 minutes, so the final 20-minute video may be fast-paced and require pausing, but should be much easier to follow along than many of my previous tutorials.
Questions / Help:
For assistance with any problems you may have following the video or in general, please post in the appropriate channel in the Knine's Scripting Lessons Discord server ( / discord . Please follow the post guidelines for the appropriate category (usually scripting) or your post may be ignored.
If you can't use Discord or don't wish to, feel free to post questions here in the comments section but know that I may be slow to answer or may miss your comment entirely. Additionally, follow these guidelines in your questions:
1) What is the specific issue you're having and what are you trying to do?
2) What have you tried to do to fix it so far?
3) Send relevant code chunks (if it's scripting) with the formatting below and any relevant errors/warnings if there are any.
Hotkeys I use:
Ctrl + L: Switch between local and global movement/rotation when building or animating (Ctrl + Y in Moon Animator I believe)
Ctrl + D: Duplicate an object in place (or on top of if collisions is turned on)
Ctrl + C, Ctrl + V: You should know what these do
Ctrl + X: Cut, which is both a delete and a copy
Alt + Click: Select an object through a group
Ctrl + Click: Add an object to the selection without removing previous selections
Ctrl + Alt + Click: Add an object to the selection through a group
This was honestly extremely helpful, thank you
Glad I could help!
yo bro, your the goat btw. I have a question i cant seem to find any video on this. How can i script an NPC that gives you this custom weapon, and transfer the weapon and its animations to the player? (without it being implemented in every starter player. i want the sword to be given Only for those who talk to the NPC.) Super helpul video !
I stan LUA
Now make elden ring
Bet.
bro what 😭 i dont get anything bro where do i even start, can you make a baby version where you explain everything such as what wait for child does, invoke server the differences etc 😭 bro ill even watch a 8 hour video to understand the same thing
Haha if you're new to scripting I would recommend the following series:
ua-cam.com/video/BfLUt3mfJiY/v-deo.html
ua-cam.com/video/BkYwRdCukZA/v-deo.html
Or you can check out some of the tutorials on the documentation like this one:
create.roblox.com/docs/tutorials/scripting/basic-scripting/intro-to-scripting
Also feel free to join the Discord server and you can ask questions about anything you want as you go along your developing journey, or not, if you don't want to.
Though I suppose I'll answer your questions really quick too:
:WaitForChild() repeatedly waits for a child (meaning something inside something else) of the provided name (inside the parenthesis), and will wait indefinitely until some child of that name is found (giving an infinite yield warning if it takes a while, but continuing to wait nonetheless)
This can be compared to simply doing something like char.Humanoid, in which you don't wait for the humanoid whatsoever, and the code will simply give an error if the humanoid isn't found or isn't loaded in in that exact moment.
Alternatively, there's also :FindFirstChild(), which takes a string/the name just like :WaitForChild() does, but it also happens in that exact moment, not waiting for the child, but rather returning "nil" rather than giving an error, if the child isn't found. :FindFirstChild() is mostly useful in cases where you don't know whether or not a child is going to exist, and you just want to check if it does or not at any given moment.
:InvokeServer() is a function of RemoteFunctions, which you can learn more about that and RemoteEvents here:
create.roblox.com/docs/scripting/events/remote
But basically the idea is that there's a client side (the player's PC) and a server side (some Roblox-owned server computer somewhere else in the world), and RemoteEvents and RemoteFunctions both allow you to communicate information between client/server. RemoteEvents simply send a signal to do something (either client -> server or vice versa), whereas RemoteFunctions are more like functions in that the "invoker" will actually wait for the "invokee" to complete it's stuff and can even get a return value before the "invoker" moves on to the next line. For example, if a client script invokes the server through a RemoteFunction, it will wait for the server to finish doing its stuff before moving on to the next line of code.
You can also probably find a variety of UA-cam videos explaining RemoteFunctions and RemoteEvents as well, but that's the general gist.
followed all the steps until 4:31, and it won't print
Disable requirehandle in the tool
im having a problem where the tool stays in my root part even when the animation is active. please help
sameee
It didn't work for a bit and I didn't know why but then I found that the tool.RequiresHandle was set to true :(
W vid tho thanks so much!
Cool
Whats on line 2 for the local script?
Tool.Equipped wont work without any handle inside how do i fix it?
add a handle inside
how do i prevent dying from breaking the whole thing
Uh do you think you could be more specific? Like dying when you're holding the weapon, dying when you're not holding the weapon, etc., as well as what you mean by "breaking the whole thing". Does it not deal damage, does it not let you equip the sword, or what specifically stops working?
@@Knineteen19 if you die well holding the weapon then equipping it nolonger clones the weapon model or enables the anims
update if you die AT ALL regardless of having the weapon equipped then it stops playing anims for the weapon and stops cloning the weapon model@@Knineteen19
If you're getting the "Cannot load the AnimationClipProvider Service" error like I am, then I'm honestly not sure what the issue is. I did some research (devforum.roblox.com/t/cannot-load-the-animationclipprovider-service/1956681 ) but everything I can find is just saying to add a small delay before running :LoadAnimation(). Even when I add a 5 second delay though, it doesn't change it and the error just comes 5 seconds later instead.@@Simply842
If you're getting a different error than the one I'm getting, then just let me know too.
try changing
local character = player.Character or player.CharacterAdded:Wait()
to
local character = player.CharacterAdded:Wait()
Output say nothing when I am at 4:30
sameee its driving me insane
now make Q to PARRY >:DDDDDD
Inside the animate thing i dont hsve torso and all that
I'm not entirely sure what part you're talking about, but it could be that the animate script was changed in recent Roblox updates or something. Can you send a timestamp for the part you're talking about?
@@Knineteen1910:20
Ah okay. I mean if you're using R15 then your script would be different since "Torso" is only for R6. It doesn't really matter though, since all you really need to change is the variable that references the player's character, since the animate script won't necessarily be inside the character model itself like it would be normally.@@RAHHHHHHHHHHHHHHHHHHHHHHHHH11
Is this out dated?
i tried to make a dual blade version and failed
could you send a tutorial on that
for some reason using events instead of functions doesnt work
If you're referring to RemoteEvents versus RemoteFunctions, note that there is a difference in the syntax of each. You can look here to see how each one works: create.roblox.com/docs/scripting/events/remote
Unless you're talking about something else when you refer to remotes and functions.
yes i did screw it up, is there a way that i can make only the final hit do knockback? i have tried it myself but activateE seems to be double fired so if i use the same system as the local script in the server script then the attack count is always increased by a random number instead of the amount its supposed to (1)@@Knineteen19
Can u give me the script
tried following this but only made it half way.. could not get the idle animation to load in. Bummer.
OnServerInvoke is not a valid member of RemoteEvent "ReplicatedStorage.Events.Weapons.ColdSteel.Equipped"
Ah it's because RemoteEvents and RemoteFunctions have different syntaxes for how they're used. This documentation page is a great quick resource for the syntax of both and also gives a good explanation of how they both work: create.roblox.com/docs/scripting/events/remote