I don't understand, the selection box won't show up no matter what I try... Maybe it's the event? If so, what would the correct event be since it's a brick?
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local SB = Instance.new("SelectionBox") Mouse.Target.MouseEnter:connect(function() if Mouse.Target.Parent:FindFirstChild("Humanoid") then SB.Parent = Mouse.Target SB.Adornee = Mouse.Target end end) Mouse.Target.MouseLeave:connect(function() if Mouse.Target.Parent:FindFirstChild("Humanoid") then SB.Parent = nil end end)
The problem is that nothing that Mouse.Target can be has the property MouseLeave or MouseEnter. What you need to do is make a check everytime the mouse is moved to check if the mouse has a Target and if the Target is was you are looking for.
local player = game.Players.LocalPlayer local mouse = Player:GetMouse() local selectionBox = Instance.new("SelectionBox") mouse.Move:connect(function() if mouse.Target then if mouse.Target.Parent:FindFirstChild("Humanoid") then selectionBox.Parent = Mouse.Target selectionBox.Adornee = Mouse.Target else selectionBox.Parent = nil selectionBox.Adornee = nil end else selectionBox.Parent = nil selectionBox.Adornee = nil end end)