Handles.MouseLeave is broken

Error: “Exception caught in TGenericSlotWrapper. Invalid value for enum NormalId”

LocalScript inside StarterPlayerScripts. Click any unlocked brick to select it. Mouse over a handle and then out of it and it will error.

Repro code:

local player=game.Players.LocalPlayer
local gui=player:WaitForChild("PlayerGui")
local mouse=player:GetMouse()

local handles=Instance.new("Handles")
handles.Style="Resize"

mouse.Button1Down:connect(function()
	local target=mouse.Target
	if target and not target.Locked then
		handles.Adornee=target
		handles.Parent=gui
	else
		handles.Adornee,handles.Parent=nil
	end
end)

handles.MouseLeave:connect(function()
	print("working")
end)

Hasn’t this been an issue for… ever? I’m gonna see if we have anything on it internally.

EDIT: Figured it out. Just a small mistake, went ahead and fixed it.

5 Likes

I’m not sure anybody’s ever actually cared to use handles.MouseLeave for any reason. I just tried using it to change the mouse icon when you mouse over a handle and change it back when you leave/let go for a demo of the resize method and noticed that it is broken.

Regardless, it’s never great to have exceptions thrown in a piece of the API!

On a slightly unrelated note, here’s something else that can throw a C++ exception in Lua.

local model = Instance.new("Model")
Instance.new("Model",model)
model.DescendantRemoving:connect(function (child)
	print(child.Parent)
end)

When this script runs, this error get’s thrown:
blob.png

My guess is that DescendantRemoving gets confused between when a player is removing an object in Lua, and when the garbage collector is doing it. So it fires before the gc can suspend the event, and since object access in Roblox is based on userdata, it tries to access the Parent property of the object when __index is called, and since the object that the Parent property is pointing to doesn’t exist, it freaks out.

That’s a fun one. I’m not sure it’s worth fixing though. :stuck_out_tongue: