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
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!