This combo isn't working!

So for the past couple of days, I’ve been working on this keybind/combo system. The keybind totally works but however, Every single time I press a key and I wait for a second, the combo doesn’t reset. It’s really frustrating and really infuriating to work with. Here’s the code (Located in StarterCharacterScripts at StarterPlayer):

spawn(function()
	if combo == 2 then
		wait(1)
		combo = 1
		print("Reset from 2")
	elseif combo == 3 then
		wait(1)
		combo = 1
		print("Reset from 3")
	end
end)

So do I remove the “spawn function” or do I keep it? Let me know! :smiley:

The way you’re doing this is inefficient, try just checking if it’s greater than one rather than making an if for each value of combo and then instead of resetting it no matter what, check if the values are the same so the combo resetting doesn’t overlap.

coroutine.wrap(function() --spawn but without a built in wait(), read about coroutines on the wiki
	if combo > 1 then --checks if the combo is greater than one
		local start = combo --sets a reference variable for what combo number you're on
		wait(1)
		if combo == start then --if the combo variable hasn't changed, reset the combo to one
			combo = 1
		end
	end
end)() --make sure to include these parenthesis otherwise the wrap doesn't run

This should work pretty well unless there’s something else manipulating it that stops it from running properly. Not really sure how else I can help you here without any other sort of context for the code.

1 Like