for i,v in pairs(script.Parent:GetChildren()) do
	if v.Name ~= "Controller" and v.Name ~= "LocalScript" then
		v.MouseEnter:Connect(function()
			CurrentlyIn = v
		end)
		v.MouseLeave:Connect(function()
			CurrentlyIn = nil
		end)
	end
end

I am recreating this: https://gyazo.com/1788876609151a856982228d6466bbed

I was thinking, when the mouse hovers over something, it is equal to Currentlyin. I would hook up that variable with a script that makes the GUI follow the mouse.

Is this a good way to do it? I think this looks better than using a bunch of math.

3 comments

0

It's always a good way until an unsolvable bug comes up, then you try a new method.

0

It's always bad practice to check if something is a class by the Name property. Compare the ClassName property of the instance instead. ' and v.ClassName ~= "LocalScript" '

0

It won't give bad performance, although you can use InputBegan and InputEnded on the Controller's and when those happen you can start dragging/stop dragging (according to the gyazo). Not need for MouseEnter and MouseLeave