I’m trying to make a chained m1 system for my sword and I don’t know how
I can get a chain of 2 to work but not three
I’ve looked through the devforum and YouTube but i cant find an answer that helps
function activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
return
end
Tool.Enabled = false
local Tick = RunService.Stepped:wait()
if (Tick - LastAttack < 0.2) then
Slash2()
elseif ("I have nothing here because I don't know what to put") then
Slash3()
else
Attack()
end
LastAttack = Tick
end
there is more to that code but it isn’t relevant to the issue
You could store a number variable called ComboChain
, which would start at 0.
Whenever the player swings in (as your script does) 0.2 seconds since the last attack, increment that counter by 1 and execute the function that corresponds to the combo chain, otherwise if the player clicks too late - reset it back to 0.
Additionally, the way of obtaining tick()
here is not ideal because it requires you to yield the script for one frame: consider using tick()
instead of that.
I don’t understand this, you said to use Tick() instead of Tick()?
I apologize for the poor wording, the way you obtain the variable “Tick” is:
local Tick = RunService.Stepped:wait()
That is not ideal because RunService.Stepped
only runs once per frame (60 times per second), instead you could just do
local Tick = tick()
to avoid the unnecessary code yield
1 Like