Error with tick()

im creating a m1 combo system but I can never continue the combo when I click

local rp = game:GetService("ReplicatedStorage")
local Combat = rp:WaitForChild("Combat")

local UIS = game:GetService("UserInputService")

local debounce = false
local cd = .25

local currTime = 0
local prevTime = 0
local count = 0

UIS.InputBegan:Connect(function(input,isTyping)
	if isTyping then
		return
	elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
		if debounce == false then
			-- debounce = true
			
			currTime = tick()
			
			local passedTime = currTime - prevTime
			if passedTime < 1 then
				print("continue combo")
				
				count = count + 1
				if count > 5 then
					count = 1
				end
				
				else
				print("reset m1 combo")
				count = 1
			end
			
			Combat:FireServer(count)
			print(count)
		end
	end
end)

Even if I click fast enough it will reset the combo

local passedTime = currTime - prevTime
			if passedTime < 1 then

You haven’t set PrevTime beyond the initial state of local prevTime = 0 anywhere so passedTime will never be less than 1. Your basically saying passedTime = tick() - 0

Oh, how would I set it to something?

Try this

local passedTime = currTime - prevTime
if passedTime < 1 then
	   print("continue combo")
				
	   count = count + 1
	  if count > 5 then
		    count = 1
	  end
				
else
    		print("reset m1 combo")
	    count = 1
end
prevTime = currTime
1 Like