SelectionBox issue

hiiii so im trya and do when the player hovers over a part itll show the selection box and when the player is not hovering over itll disappear. Id like it to be on the client but it doesnt work heres my current code in starterplayerscripts

`'local blocksFolder = workspace.Blocks
local selectionBoxTemplate = Instance.new(“SelectionBox”)
selectionBoxTemplate.Color3 = Color3.new(1, 0, 0)
selectionBoxTemplate.LineThickness = 0.1
selectionBoxTemplate.Transparency = 1

for _, dirtBlock in ipairs(blocksFolder:GetChildren()) do
if dirtBlock:IsA(“Model”) then
local selectionBox = selectionBoxTemplate:Clone()
selectionBox.Adornee = dirtBlock
selectionBox.Parent = dirtBlock

    dirtBlock.MouseEnter:Connect(function()
        selectionBox.Transparency = 0
    })

    dirtBlock.MouseLeave:Connect(function()
        selectionBox.Transparency = 1
    })
end

end
`’

1 Like

The problem is the dirtBlock.MouseEnter, a Model doesnt have a Signal for MouseEnter and MouseLeave, you can use a Click Detector for that, so instead of dirtBlock.MouseEnter/MouseLeave you do clickDetector.MouseHoverEnter/MouseHoverLeave

1 Like

Thing is, this might look a bit odd for the player. Instead, you could check the mouse’s .Target property.

how do i do that, any idea?, I Appreciate anything

Its a part but yeah think it stills applies for both so thanks!

Use Player:GetMouse().Target.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.