Player can trigger 2 UIS events at once that have checks not to be used at once

I’m working on a soulslike game with multiple characters, abilities for the characters are not meant to be used at the same time and have checks to stop this.
When a player presses 2 keys at the same time the system ignores the Booleans that check to see if another ability or attack is running because they start at the same time before the Boolean is enabled.
I have tried adding debounces checks like “isusing___” etc but when two UIS events fire at the same time they start before the booleans are enabled, I have also tried adding slight waits in each ability of a different time but it made the combat feel a little unresponsive and clunky.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Watch examplehg | Streamable – video example

if isTyping then return end
if isswinging then return end
if Character.isinattack.Value == true then return end
if Character.isindash.Value == true then return end
if Character.Vulnerable.Value == true then return end
if input.KeyCode == Enum.KeyCode.F then
2 Likes

This is really hard to read and correctly respond to. Can you try using triple ` to make code like this?

local foo = true
local bar = false

if foo and not bar then
	print(foo)
end
2 Likes

I changed it, thank you for bringing that to my attention :slight_smile:

1 Like

Thanks for changing it! Now, in the video, it looks like the player swings before the block. You could potentially be not changing the isswinging value, or you should try debugging by adding a print statement before the start of your checks like this: print(isTyping,isswinging,Character.isinattack.Value,Character.isindash.Value,Character.Vulnerable.Value)

Also, I noticed that isswinging is not referring to a value, but I assume you already know this.

2 Likes

It seems when two actions start at the same time all the checks return false however when I check while the actions run, their respective checks return true but the action has already started, I could probably cancel all actions early when they have the checks return true mid action.

1 Like

My guess is that you do not immediately apply the value to true, meaning players can still use other moves during it.

1 Like

Aside from a slight jumpy movement from canceling an action, although the values were applied at the start, checking during the action and canceling it when it returned true fixed the player pressing both keys at once.
Thank you for your help!! Have a great rest of your day : )
Watch hfddh | Streamable – video of the fix

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.