I need help with making a selection box when hovering over a part and whenever the mouse leaves it goes away.
a bit like when you select things
I need help with making a selection box when hovering over a part and whenever the mouse leaves it goes away.
a bit like when you select things
oh thanks i’ll give it a read.
i will leave the post up see if anyone else has a better script for this
I guess selection box is the best thing you can use.
oh i never thought of using anything else other than Selection Boxes!
i mean like the code for the selection box
You can setup a mouse.Move event, check if the mouse.Target == yourPart
if it is then
local box = Instance.new("SelectionBox")
box.Parent = yourPart
box.Adornee = yourPart
else
if yourPart:FindFirstChild("SelectionBox") then
yourPart.SelectionBox:Destroy()
end
Example:
(Local script, StarterPlayerScripts)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local part = game.Workspace:WaitForChild("yourPartsName")
mouse.Move:Connect(function()
if mouse.Target == part then
local box = Instance.new("SelectionBox")
box.Parent = yourPart
box.Adornee = yourPart
else
if yourPart:FindFirstChild("SelectionBox") then
yourPart.SelectionBox:Destroy()
end
end
end)
Edit: changed a quote mark from the mobile version (“ to ")
or if the part actually has a reason to be selected like having a clickdetector they can use this instead
local part = script.Parent
part.ClickDetector.MouseHoverEnter:Connect(function()
part.SelectionBox.Visible = true
end)
part.ClickDetector.MouseHoverLeave:Connect(function()
part.SelectionBox.Visible = false
end)