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

in pairs loop referencing the wrong object?

Asked by 4 years ago
Edited 4 years ago
--localscript
for i, c in pairs(game.Workspace.Doors:GetChildren()) do
    if c:FindFirstChild('Part') then
        v=c.Part:FindFirstChild('ClickDetector')
        v.MouseHoverEnter:Connect(function()
            v.Parent.SelectionBox.Visible=true
        end)
        v.MouseHoverLeave:Connect(function()
            v.Parent.SelectionBox.Visible=false
        end)
    end
end

Hi, made a script where I just want a selection box to appear on the parent of the clickdetector I hover over, however this produces this result https://gyazo.com/9dad99ea038c7f619cd804125aee144b

Here is the folder in workspace:

https://gyazo.com/9a159bd1f1ddd5b179a83daafc29f5c5

Is there any way or fix to this script to enable me to have the selection box appear for only the clickdetector I actually hover my mouse over? Thanks.

Answer this question