I have a bug where in my “Shovel” tool, there is a server cooldown. When I dig with it, it works. But when I dig while someone else digs it doesn’t work. Im positive this is a cooldown issue on the server. I have tried Bindable functions, Delay, and Spawn. I use a table to store the players in the cooldown.
The table is called “ShovelCooldown”
Server, Remove the player from the cooldown table.
This might not be exactly what you’re asking for, but if I were making this system, I would keep everyone’s last dig time in a table that you can reference at any time. No need to add/remove them from the table multiple times in a session.
local shovelCooldowns = {}
local cooldownTime = 5
local digEvent = Instance.new("RemoteEvent")
digEvent.Name = "DigEvent"
digEvent.Parent = game.ReplicatedStorage
game.Players.PlayerAdded:connect(function(player)
shovelCooldowns[player] = 0
end)
game.Players.PlayerRemoving:connect(function(player)
shovelCooldowns[player] = nil
end)
digEvent.OnSeverEvent:connect(function(player)
local lastUse = shovelCooldowns[player]
if tick()-lastUse < cooldownTime then
return
else
shovelCooldowns[player] = tick()
-- dig!
end