local module = {}
function module.Function (player)
local combo = player.PvPStats:FindFirstChild("Combo")
local combocounter = player.PlayerGui.ComboCounter
local textlabel = combocounter.Frame.TextLabel
local hittick = tick()
if combo then
combo.Value += 1
combocounter.Enabled = true
textlabel.Text = combo.Value
print(combo.Value)
else
local newcombo = Instance.new("NumberValue")
newcombo.Name = "Combo"
newcombo.Parent = player.PvPStats
print(newcombo.Value)
end
end
return module
this module is called everytime you damage someone with a tool but how would i reset it if the player has stopped comboing?
One way to do it is to use a timer to track when the reset occurs. This timer module or this one should work.
Here’s the logic:
When you first damage someone create the timer and start it.
When you damage them again check to see if the timer has already been created. If so then reset the current time to it’s original state to refresh the combo timer.
Set an event for when the timer ends which resets the combo counter and also destroys the timer.
You could reset the time after detecting the amount of seconds had passed. For example…
Ratelimit check:
local rateData = {}
local resetRate = 1 -- How long the interval would be to reset the rate
local maxRates = 3 -- Max rates within "resetRate" interval (1 second)
function RateCheck(player)
local currentRData = rateData[player]
if not currentRData then
local newRData = {
Rates = 0;
LastReset = os.time();
}
rateData[player] = newRData
currentRData = newRData
end
local canReset = os.time()-currentRData.LastReset
if canReset then
currentRData.LastReset = os.time()
currentRData.Rates = 0
end
local passRate = currentRData.Rates+1 <= maxRates
currentRData.Rates = currentRData.Rates+1
if not PassRate then
return false
else
return true
end
end
for i = 1,5,1 do
local didPass = RateCheck(game:GetService'Players'.trzistan) -- Checking rate spam from me. Feel free to change "trzistan" to your username.
warn(i.." Attempt:", didPass)
wait(0.01) -- Waiting every hundredth of a second
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Timer = require(ReplicatedStorage.ModuleScripts.Timer)
local module = {}
function module.Function (player)
local combo = player.PvPStats:FindFirstChild("Combo")
local combocounter = player.PlayerGui.ComboCounter
local textlabel = combocounter.Frame.TextLabel
local ComboTimer = Timer.new(1.75)
if ComboTimer:GetRemaining() == 1.75 then
ComboTimer:Start()
print("combo timer started")
elseif ComboTimer:GetRemaining() < 1.75 then
ComboTimer:Stop()
local ComboTimer = Timer.new(1.75)
ComboTimer:Start()
print("combo timer restarted")
end
ComboTimer:OnStopped(function()
print("stopped")
end)
end
return module
for i,v in pairs(GetTouchingPartsModule.Function(hitbox)) do
if v.Parent ~= player.Character and v.Name == "HitBox" then
if not v.Parent:FindFirstChild("ForceField") then
local player2 = game.Players:FindFirstChild(v.Parent.Name)
local blocking = BlockingList:FindFirstChild(v.Parent.Name)
if blocking then
v.Parent.Humanoid.Health = v.Parent.Humanoid.Health - blockedDamage
Tag.Function(player)
if player2 then
Tag.Function(player2)
HitBlocked.Function(v.Parent,player2)
else
HitBlocked.Function(v.Parent)
end
else
Combo.Add(player)
ComboTimer:Reset()
ComboTimer:Start()
M1Module.Function(v.Parent,player)
v.Parent.Humanoid.Health = v.Parent.Humanoid.Health - Damage
Tag.Function(player)
if player2 then
Tag.Function(player2)
end
ComboTimer.Completed:Connect(function()
Combo.Stop(player)
end)
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local combo = {}
function combo.Add (player)
local combo = player.PvPStats:FindFirstChild("Combo")
if not combo then
local combo = Instance.new("NumberValue")
combo.Name = "Combo"
combo.Parent = player.PvPStats
combo.Value = combo.Value + 1
else
combo.Value = combo.Value + 1
end
end
function combo.Stop (player)
local combo = player.PvPStats:FindFirstChild("Combo")
combo.Value = 0
end
return combo