Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The gun stops shooting after a couple shots, why is that? [SOLVED]

Asked by 3 years ago
Edited 3 years ago

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)

1 answer

Log in to vote
0
Answered by 3 years ago

I just needed to make a skybox

Ad

Answer this question