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

How do i make parts have an outline when the mouse hovers over them?

Asked by 3 years ago

I'm making a game and I want to have selection boxes when you have a hover over a object and it also needs to only Apply the selection box when a part has a specific child And I can't figure out how to do that

Thanks in advance

1 answer

Log in to vote
0
Answered by 3 years ago

To do this, you will need to do this in a local script placed in starter player scripts, starter gui, or other places where local scripts run.

First of all you will need to create a selection box and get the Player's mouse like this:

local selection_box = Instance.new("SelectionBox")
-- you can custimize it however you like eg: selection_box.Color3, selection_box.LineThickness, selection_box.SurfaceColor3, selection_box.SurfaceTransparency, selection_box.Transparency


local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Then you will need to create an event that triggers when the mouse moves using the Mouse.Move() event:

local selection_box = Instance.new("SelectionBox")
-- you can custimize it however you like eg: selection_box.Color3, selection_box.LineThickness, selection_box.SurfaceColor3, selection_box.SurfaceTransparency, selection_box.Transparency


local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Move:Connect(function()



end)

Next, you will need to get the mouse's target using the Mouse.Target and check if it has a target and meets the requirement:

local selection_box = Instance.new("SelectionBox")
-- you can custimize it however you like eg: selection_box.Color3, selection_box.LineThickness, selection_box.SurfaceColor3, selection_box.SurfaceTransparency, selection_box.Transparency


local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Move:Connect(function()
local target = Mouse.Target
if target and target:FindFirstChild(the name of the child it needs to have) then
selection_box.Adornee = target


else

selection_box.Adornee = nil

end

end)

Hope I helped!

Ad

Answer this question