Breakdown a sword into a series of steps you need to script it. Use a tree diagram. For eg, we need to do hitdetection, now break that into smaller components to think how to script that.
There’s multiple ways to do hitdetection such as .Touched, raycasting, roatated region3. (Don’t use magnitude lol).
Sorry for the late reply. I’m trying to make a sword combo system like you find in Tales from The Valley or Rogue Lineage. after some time, the combo resets.
EDIT: So basically, the first hit is a different animation, 2nd hit is a different animation, and so on. If you do the 2nd hit, and wait for too long it resets back to the first one. Hopefully that clears that up.
I would like it do the different animation even if they did not hit anything, and how would I tell the script that “Hey, this user has did the first hit. Proceed on with the 2nd animation.” I also don’t know how to make a hitbox for it
local Tool = script.Parent
local Anim1 -- 1st anim
local Anim2 -- 2nd anim
local Anim3 -- 3rd anim
local anim1trigger = true
local anim2trigger = false
local anim3trigger = false
Tool.Activated:Connect(function()
if anim1trigger == true and anim2trigger == false and anim3trigger == false then
Anim1:Play()
anim2trigger = true
anim1trigger = false -- dont know how to add the hitbox here
elseif anim2trigger == true and anim1trigger == false and anim3trigger == false then
Anim2:Play()
-- dont know how to add hitbox
anim3trigger = true
anim2trigger = false
elseif anim3trigger == true and anim2trigger == false and anim1trigger == false then
Anim3:Play()
-- idk how to add hitbox
anim3trigger = false
wait(1)
anim1trigger = true
wait(2)
if anim1trigger == false then
anim1trigger = true
anim2trigger = false
anim3trigger = false
end
end-- and the ends
end)
I’ve just replied you with a quote of 0Shank of ways on hitdetection.
Why would you potentially want to make a sword, out of nowhere?
local Tool = script.Parent
local Anim = -- 1st anim
local Anim2 = -- 2nd anim
local Anim3 = -- 3rd anim
local anim1trigger = true
local anim2trigger = false
local anim3trigger = false
Tool.Activated:connect(function()
if anim1trigger == true and anim2trigger = false and anim3trigger = false
then
Anim1:Play()
anim2trigger = true
anim1trigger = false
-- dont know how to add the hitbox here
elseif anim2trigger == true and anim1trigger == false and anim3trigger == false then
Anim2:Play()
-- dont know how to add hitbox
anim3trigger = true
anim2trigger = false
elseif anim3trigger == true and anim2trigger == false and anim1trigger == false then
Anim3:Play()
-- idk how to add hitbox
anim3trigger = false
wait(1)
anim1trigger = true
wait(2)
if anim1trigger == false then
anim1trigger = true
anim2trigger = false
anim3trigger = false
-- and the ends
EDIT: for your first question, I literally do not know how to activate the hitbox and disable it, yes, I know touched, raycasting and region3 all exist but I don’t know how to work them.
for your second question, someone just animated swords for me yesterday
for your third question, your answer was a bit unexplanatory, so I made a test script wondering if this was going to work
A month ago I started developing my own type of tool system.
Roblox’s tool system is embedded into it and can get a bit confusing. So I took the liberty of creating a whole new system from scratch. I feel as though this would be easiest for you.
In a ServerScript you will need:
A way to clone the model into the player’s hand, you should store all tool models in ReplicatedStorage and use :Clone() to clone.
A way to weld the tool to the player’s hand, this works for models if you weld everything in it together. I suggest using a free weld script.
A damage script attached to the blade of the sword. This can be done from the serverscript or from a script inside the model. I prefer it being inside the model so that different tools have different damages.
An animation player so that whenever the weld is connected to the players hand and the player pressed lmb the sword swings. It would be better to have this inside the sword as well.
A way to log player’s keypresses so that you can swap the weapon they are holding when the press something like 1 or 2.
Etc…
This is my way of doing it, and if you want I can send you my current progress on the tool project.
You should most likely start on touch functions first and all of that, then start to get to mouse functions, etc. Raycasting is also possible, like in ROLVE games.
Well, if it’s a simple sword script then it’s simple and easy to script but if it requires stuff like special movements, abilities, etc. then it’ll take like almost 4 hours to completely make an advanced sword tool system, you should start with some variables that the tool contains, add some boolean variables like cooldown, slash debounce, debounce where it sees if it’s slashing or not, and some int64 or float variables for cooldown, damage, etc.
Start by creating a equipped function if you have an equip animation, make it play then after it ends, the idle animation plays, if the tool gets activated, play the slash animation and add stuff like enabling the canDamage boolean and create another script that’ll manage the damage.
Don’t forget to create an unequipped function in the same script with the equipped and activation function so you won’t be stuck in the idle animation. Make sure the equipped, activation, unequipped functions are in client so it fires more instantly, and the damage script as a normal script, that’s what i do atleast to create a melee tool system.