got a simple grid-placement system script. a Snap-to-grid function is called after a New Block function. This snap to grid listens to mouse movements and snap to grid. but it also listens to Activated by Tool and assigns it a function. That function takes it from here and disconnects the other functions and resets the program. Heres the problem; it wont disconnect itself. It instead re-iterates itself ~100 times. Ive designed this to be un-noticable to the player, but you can imagine having 100 calls not good for performance.
This is the function and where its being called from:
function
print("Mouse moved")
Deactivate=false
_G.Activate = script.Parent.Activated:Connect(Activated)
end
function Activated()
print("Activated")
if Deactivate == false then
Deactivate = true
NewBlock.Transparency = 0
NewBlock=nil
if Module.InventoryHandler("read", "Block2x") > 0 then
_G.mousemoved:Disconnect() --deactivate snap-to-grid
_G.Activate:Disconnect() --deactivate itself after use. WONT WORK
_G.equip:Disconnect() --disconnect the New block script just in case its still running
_G.equip = script.Parent.Equipped:Connect(_G.NewBlock) --recall it to place another block
else
_G.equip:Disconnect()--same thing but if they have no blocks left in inv
_G.mousemoved:Disconnect()
_G.Activate:Disconnect()
end
end
end
"New block called Activated (x183) Mouse moved (x37)" that is the print statements. as you can see, a new block is called and the mouse moved function is disconnected. but it definitely doesnt disconnect itself and acts as if the block was infinitely activated. it does stop, but at 100+
