Is there a way to put a selection box only around one part when the players mouse is in front of it... The wiki shows how to put a selection box around every part but I want it to do it for only one part So if it was over a players torso It would add a selection box around it.. I dont want to request I just want an Idea of how to do it! :D Thanks!
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local targets = { Torso = true , HumanoidRootPart = true } |
04 | local sel = Instance.new( "SelectionBox" , player.PlayerGui) |
05 |
06 | mouse.Move:connect( function () |
07 | if mouse.Target and targets [ mouse.Target.Name ] then |
08 | sel.Adornee = mouse.Target |
09 | else |
10 | sel.Adornee = nil |
11 | end |
12 | end ) |
Hello Timster111!
Yes, there is a way to put a selection box over just a part. Just set the Selection Box's Adornee property to the part in question. Your question about putting it over a part hovered over by the mouse is a tad bit trickier, but very doable.
01 | --note that this needs to be in a local script |
02 | --define variables |
03 | local m = game.Players.LocalPlayer:GetMouse() |
04 | local IsBoxUp = false |
05 | local BoxedPart = nil |
06 |
07 | --set an anonymous function to run every time the player moves his mouse |
08 | --you can use a while loop if you want it to check constantly, but I find this to be less of a strain |
09 | m.Move:connect( function () |
10 | if m.Target then |
11 | if not IsBoxUp then --make the box |
12 | IsBoxUp = true |
13 | BoxedPart = m.Target |
14 | sb = Instance.new( "SelectionBox" , m.Target) |
15 | sb.Adornee = m.Target |