I made an assault rifle with automatic firing, but if I quickly press the firing button several times, the firing script is triggered several times, and it turns out that the rifle makes several shots at once. How can I fix this?

Local Script

Mouse.Button1Down:Connect(function()
	
	script.Parent.shot.Value = true
	
	while true do
			
		if script.Parent.shot.Value == false then
			break
		end
	
		RemoteEvent:FireServer(Mouse.hit.p)
		
		wait(0.4)

	end
	
end)

Mouse.Button1Up:Connect(function()

	script.Parent.shot.Value = false
	
end)

Server Script

local Speed = 500
local BulletSize = Vector3.new(0.5,0.5,0.5)

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,Pos)
	
    local Origin = TOOL.Handle.CFrame.Position
    local Bul = Instance.new("Part")
	local bod = Instance.new("BodyVelocity")

    Bul.Size = BulletSize
	Bul.Material = ("Neon")
	Bul.CanCollide = false
	
	local dmg = script.Parent.DamageScript:Clone()
	dmg.Parent = Bul
	dmg.Disabled = false
	
	local own = Instance.new("StringValue")
	own.Parent = Bul
	own.Value = TOOL.Parent.Name
	
	Bul.CFrame = CFrame.new(Origin) * CFrame.new(0,0,1)
	bod.Parent = Bul
    bod.Velocity = (Pos - Origin).Unit*Speed
	Bul.Parent = workspace
	script.Rifle:Play()	

end)

Sorry for my English, I use google translate :)