I made this gun for my game and everything works except you can easily just spam click and deal tones of damage, your only supposed to be able to shoot every .15 seconds, here’s what I mean:
Holding down the mouse:
Spam clicking:
Here’s my script, its quite long so I removed a lot of unnecessary stuff to make it less confusing and show the actual important stuff. Any help would be appreciated, Merry Christmas
local tool = script.Parent
local fireRate = 1.5
local shooting = false
local shootDb = true
tool.Equipped:Connect(function(mouse)
tool.Activated:Connect(function()
if shootDb == true then
shootDb = false
shooting = true
while shooting do
if shootDb == false then
-- gun stuff
end
wait(fireRate)
end
end
end)
tool.Deactivated:Connect(function()
shooting = false
wait(fireRate)
shootDb = true
end)
tool.Unequipped:Connect(function()
shooting = false
shootDb = true
end)
end)