Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Will this give bad performance and is it good practice?

Asked by 4 years ago
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.

0
It's always a good way until an unsolvable bug comes up, then you try a new method. thesit123 509 — 4y
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" ' pidgey 548 — 4y
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 pidgey 548 — 4y

Answer this question