Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why this combo counter not works? i checked click detact is not problem.

	click.OnServerEvent:Connect(function(plr,attack)					--Sword
		local combo = 1
		if tick()-last > 2 or combo <= 4 then
			combo = 1
		else
			if combo == 1 then	
			end
			if combo == 2 then
			end
			if combo == 3 then
			end
			if combo == 4 then
			end
			combo = combo + 1
			last = tick()
			print(combo)
		end
	end)

5 comments

0

that script is not prints combo

0

Try to show client script. It maybe because this is don't triggers. Also you need put print not in the "else"

0

local mouse = player:GetMouse() mouse.Button1Down:Connect(function() click:FireServer() end)

0

ops i need to change combo = tick() to last = tick()

0

not works

1 answer

I'd assume that's because you are setting the variable to 1 every time the event is fired, so try using a table or IntValue to store individual player's combo counter

local comboCounter = {}
local lastTick = {}

game.Players.PlayerAdded:Connect(function(player)
	comboCounter[player] = 0
	lastTick[player] = 0
end)

click.OnServerEvent:Connect(function(player)
	if tick() - lastTick[player] > 2 or comboCounter[player] <= 4 then
		comboCounter[player] = 1
	else
		if comboCounter[player] == 1 then  
		end
		if comboCounter[player] == 2 then
		end
		if comboCounter[player] == 3 then
		end
		if comboCounter[player] == 4 then
		end

		comboCounter[player] =+ 1
		lastTick[player] = tick()
		print(comboCounter[player])
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.