How do I make my gun fully automatic?

  1. What do you want to achieve? I want to turn my gun from semi-automatic to fully-automatic.

  2. What is the issue? I have no idea what code makes a gun turn fully-automatic.

  3. What solutions have you tried so far? I’ve tried numerous YouTube videos and searching on Google.

My current server script:

script.Parent.Fire.OnServerEvent:Connect(function(player,mousePos)

player.Character.M4A1.Sound:Play(4642718673)

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

local raycastResult = workspace:Raycast(script.Parent.Handle.Position,(mousePos - 
	script.Parent.Handle.Position)*300,raycastParams)

if raycastResult then
	local hitPart = raycastResult.Instance
	local model = hitPart:FindFirstAncestorOfClass("Model")

	if model then
		if model:FindFirstChild("Humanoid")then
			model.Humanoid.Health -=50
		end
	end
end

end)

you might want to try to use remote events like “fire” and “stopfiring” or something like that, that will turn on a boolean of “firing”. After this, you could use repeat inside of the script by adding a few lines in the code like this:

repeat
--- the firing part of the script
until script.Parent.Firing.Value == false

or something along those lines

1 Like