Mousebutton1click fires multiple time instead of once

Here is the script,when I click it while hovering over the specific part it prints innit bruv multiple times instead of once,any help?

local Mouse = game.Players.LocalPlayer:GetMouse()
local player = game.Players.LocalPlayer
local character = player.Character
while true do wait()
	local ray = Ray.new(
	        Mouse.Origin.p,
	        Mouse.UnitRay.Direction * 50
	)
	 
	local hit = workspace:FindPartOnRay(ray, character)
	local name = hit ~= nil and hit.Name
	if name == "Alt" then
		Mouse.Button1Down:connect(function()
			print("innit bruv")
		end)
	end

end


local Mouse = game.Players.LocalPlayer:GetMouse()
local player = game.Players.LocalPlayer
local character = player.Character
local dis = false
while true do wait()
	local ray = Ray.new(
		Mouse.Origin.p,
		Mouse.UnitRay.Direction * 50
	)

	local hit = workspace:FindPartOnRay(ray, character)
	local name = hit ~= nil and hit.Name
	if name == "Alt" then
		Mouse.Button1Down:connect(function()
			if dis == false then
				dis = true
				print("innit bruv")
				wait(1.5) -- Set it to 0 or choose a wait time
				dis = false -- Delete if not: If you want to be able to print again then don't delete
			end
		end)
	end	
end	

You are a lifesaver thank you soo much :heart: :heart:

1 Like