Don't know where to start with sword script

You can write your topic however you want, but you need to answer these questions:

  1. I have sword animations made by a friend, and I wanna script it.
  2. The issue is I have no idea where to start.
  3. I searched around Resources about sword scripts but I haven’t found any.

There’s plenty of ways to learn to make a sword, try searching for the free model and learning from it, try youtube videos, etc…

Videos that could be useful:

I hope this solved your problem, thanks for reading, have an amazing rest of your day/night.

1 Like

I agree with this, this topic is kinda unnecessary since there are WAY too many videos about that

1 Like

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.

Check if the player hit something once between a time period, then if he hits again, do a different animation.

1 Like

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

Then simply make it so you load a different animation everytime the user unleashes a attack.

Answer:

Yes, but like I said here,

How would I do that?

local defaultanim = --
wait(5)
defaultanim = --

Edit (Answer?):

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)
  1. I’ve just replied you with a quote of 0Shank of ways on hitdetection.
  2. Why would you potentially want to make a sword, out of nowhere?
  3. What you expect me to say?
1 Like

I was thinking something like this:

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:

  1. A way to clone the model into the player’s hand, you should store all tool models in ReplicatedStorage and use :Clone() to clone.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Etc…

This is my way of doing it, and if you want I can send you my current progress on the tool project.

1 Like


So this is what I have, could I get help welding it all together?

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.

Thanks, how would I enable and disable the touched? So whenever the swing animation is played, the touch function is enabled

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.

3 Likes