I want to know how to simplify this button1down script.

local ButtonDown = false
local mouse = game.Players.LocalPlayer:GetMouse()

function FireGun()
	print("GunFired")
end

mouse.Button1Down:connect(function(click)
	ButtonDown = true
	while ButtonDown == true and wait(0.1) do
		FireGun()
	end
end)

mouse.Button1Up:connect(function(click)
	ButtonDown = false
end)

Is there a better way to do this like in the method for touched events;

part.Touched:connect(function()
part.TouchEnded:connect(function()
end)
end)

2 comments

0

It seems symplified to me, im not sure how to symplfy it more

0

This code is good.