Hi, I am trying to code a system for a game’s sword combat.
The sword is meant to cycle through three different animations:
1: The initial swing (only play this on combo start)
2: Combo swing 1
3: Combo swing 2
I know how to set up:
Changing the combo value
Looping back to combo = 2 when the combo is continued
Applying animations to combo value
However, I am having some trouble in resetting the combo back to zero. What I am trying to make is that if the player does not make an input within a set window after an attack, the combo resets to 0.
I have looked through several tutorials and devforum posts, and for some reason, those do not work when I try to use them. I am currently using a timer module recommended for combos, however that has several conflicts with my other scripts, more specifically the ones involving a dash feature.
I have also tried looking into an open source sword game (specifically this one: Sword Combat Test - Roblox) and while I can see a combo system, I do not know how it resets.
If anyone knows any good methods for resetting a combo that is not a module(I kind of want to figure it out without the use of modules), please let me know.
If needed, I can post my current sword combo script.
So basically, all it does is return how many seconds have passed since 1970.01.01. And you can save this every time the player swings, and then check at the next swing how much time has passed since then.
local swingTimer = 0
local resetTime = 3 -- after how many SECONDS does it reset
--Swing action
if swingTimer < tick() - resetTime then
--reset combo
else
swingTimer = tick()
--slash
end
Ok, so it appears that I have somehow inversed this.
When I click in the window, it cancels the combo. If I wait for 3 seconds then it continues the combo.
Is combo a NumberValue or a variable? If it is a variable, not an actual Instance inside the workspace, you don’t need to use .Value, just say combo > 3 and combo += 1. The error says that its a variable, not a NumberValue
Sorry, but even after the code change, the script still doesn’t work.
The output states that the combo keeps getting stuck at the cancel and does not increase the combo at all. However, if I use the original code, the combo system reverses, only increasing combo if I click after 3 seconds rather than the inverse.