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)
COMMUNITY QUESTION
why this combo counter not works? i checked click detact is not problem.
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.

5 comments
that script is not prints combo
Try to show client script. It maybe because this is don't triggers. Also you need put print not in the "else"
local mouse = player:GetMouse() mouse.Button1Down:Connect(function() click:FireServer() end)
ops i need to change combo = tick() to last = tick()
not works