Script still recognizes Mousebutton1 click even tho it shouldnt

nope does the same thing it did before

Hmm, this is quite confusing, when you said print(dis) printed numbers, what were they?

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)
	if hit ~= nil then
    	local name = hit.Name
    	if name == "Alt" then
    	    local Connection
    	    local function MouseClick()
    	        Mouse.Button1Up:Connect(function()
	              Connection:Disconnect()  
	            end)
	    		if dis == false then
	    			dis = true
	    			print("innit bruv")
	    			wait(0) 
	    			dis = false 
	    		end
	    	end
    	 end
	     Connection = Mouse.Button1Down:Connect(MouseClick)
	end
end

It printed a random number with a lot of decimals and if I moved slightly it would change

Were any of the numbers greater than 50?

some where but most were around 30 I think

yes that is the one I said had the error in line 17 or 18 with the Disconnect

I changed the script it’s different now.

Okay I just realised taht my dis variable had the same name as the debounce. Try this

local player = game.Players.LocalPlayer
local character = player.Character
local Mouse = player:GetMouse()
local dis = false

Mouse.Button1Down:connect(function()
	local distance = (Mouse.Hit.p - character.HumanoidRootPart.Position).magnitude
	local hit = Mouse.Target
	local name = hit ~= nil and hit.Name
	if distance <= 50 and name == "Alt" and not dis then
		dis = true
		print("innit bruv")
		wait() 
		dis = false 
	end
end)

works on ground but as before after I take off it stops working. ok this approach is prob broken (again) I really dont know how to do this then… What do I make a custom click detector or smth?

What happens when you try to click when the plane is taking off?

it doesnt do anything and it stops printing innit bruv

local name = hit ~= nil and hit.Name
print(distance,name)
if distance <= 50 and name == "Alt" and not dis then

Place that print between those 2 lines and try clicking when it’s taking off to see what it prints

it prints number,false or number,meshpart(which is the big mesh part behind the button)

Hmm, I’m not sure what to do relating to that since I never had to compensate for stuff like that