If I click in the boundary, everything is fine. If I click outside the boundary it returns Out of bounds (x2)
, if I click outside again it returns Out of bounds (x8)
and keeps increasing until it reaches something crazy like (x8432)
, when the game lags out and crashes.
function Place() if Placing == true and Debounce == true then Mouse.Button1Down:connect(function() Debounce = false if InBoundary == true and IsColliding == false and Placing == true then -- irrelevant code if Mouse.Target == nil then return end if Placing == true then Mouse.TargetFilter = nil Placing = false elseif not Placing then return end Placing = false elseif InBoundary == false then print("Out of bounds.") Blink() Place() elseif IsColliding == true then print("Object already here.") Blink() Place() end Debounce = true end) end end
How can I fix this? I tried adding a Debounce.
I think you need to disconnect it
function Place() if Placing == true and Debounce == true then local bt; bt = Mouse.Button1Down:Connect(function() --USE "Connect" !!!!! "connect" is deprecated!!!!!!!! Debounce = false if InBoundary == true and IsColliding == false and Placing == true then -- irrelevant code if Mouse.Target == nil then return end if Placing == true then Mouse.TargetFilter = nil Placing = false elseif not Placing then return end Placing = false elseif InBoundary == false then print("Out of bounds.") Blink() Place() elseif IsColliding == true then print("Object already here.") Blink() Place() end Debounce = true bt:Disconnect() end) end end