I have a script that gives the gun if you are on a certain team, when the player gets the gun, they can shoot multiple times after the gun stops working (on average 2), why is that? There are no errors in the output.
local script:
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() script.Parent.Activated:Connect(function() game.ReplicatedStorage.ShootEvent:FireServer(Mouse.Target, Mouse.Hit.Position) end)
server script:
local dbinterval = 0.5 db = false game.ReplicatedStorage.ShootEvent.OnServerEvent:Connect(function(Player, MouseT, MouseP) if not db then db = true script.Parent.GunFlash.SurfaceLight.Enabled = true script.Parent.PistolSound:Play() wait(.1) script.Parent.GunFlash.SurfaceLight.Enabled = false if MouseT ~= nil then if MouseT:FindFirstAncestorOfClass("Model") ~= nil then if MouseT:FindFirstAncestorOfClass("Model"):FindFirstChild("Humanoid") then MouseT:FindFirstAncestorOfClass("Model"):FindFirstChild("Humanoid"):TakeDamage(20) elseif db then wait(dbinterval) db = false end end end end end)