Combat Combo Reset

what am i trying to accomplish? simple, a combo reset for my combat
what is the problem? the variable count, which is a number is not increasing and is staying 0 even when i increase it
the code:

local uis = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
local combat = script:WaitForChild("RemoteEvent",3)

local stat = game.Players.LocalPlayer:WaitForChild("Player_Stats",3)
local character = game.Players.LocalPlayer.Character

local debounce = false 

local currTime = 0 
local prevTime = 0

local cd = .6 
local count  = 0




uis.InputBegan:Connect(function(input,isTyping)
	if isTyping then
		return
	else
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			if character["Right Arm"]:FindFirstChild(stat.Weapon.Value) or character:FindFirstChild("WeaponEquipped") then return end 
			if debounce == false then 
				debounce = true 
				currTime = tick()
				local passedTime = currTime - prevTime
				
				
				
				if  passedTime < 1 then 
					count = count + 1 
					print(count)
					if count > 5 then 
						count = 0
					end
				else 
					count = 0
				end
				if count > 0 then
					combat:FireServer(count,mouse.Hit.Position)
				else 
				print("Count is 0")
				end
			end
		end
	end
end)

combat.OnClientEvent:Connect(function()
	wait(cd)
	debounce = false 
end)
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rightArm = character:WaitForChild("Right Arm")
local mouse = player:GetMouse()

local playerStats = player:WaitForChild("Player_Stats")

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")

local debounce = false 

local currTime = tick()
local prevTime = tick()
local count  = 0

userInput.InputBegan:Connect(function(input, processed)
	if processed then return end
	if debounce then return end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		local weapon = rightArm:FindFirstChild("Weapon")
		if weapon then
			if weapon.Value then return end
		end
		
		local equipped = character:FindFirstChild("WeaponEquipped")
		if equipped then return end
		
		debounce = true
		
		currTime = tick()
		local passedTime = currTime - prevTime
		prevTime = tick()
		
		if passedTime > 1 then
			count = 1
		else
			count += 1
		end

		if count > 0 then
			remote:FireServer(count, mouse.Hit.Position)
		end
		
		task.wait(1)
		debounce = false
	end
end)

Here you go, and move the RemoteEvent to the ReplicatedStorage container.

1 Like