I’m trying to get it so that when my mouse hovers over a part, a highlight object gets added to that part.
The current script I’m using is not working, not sure why.
local outline = script:WaitForChild("Selection")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
outline.Parent = plr:WaitForChild("PlayerGui")
mouse.Move:Connect(function()
local target = mouse.Target
for _,blocks in pairs(workspace.Blocks:GetChildren()) do
if target == blocks then
outline.Adornee = blocks
else
if (outline.Adornee == blocks) then
outline.Adornee = nil
end
end
end
end)
Hi , i tried the script on my end and it worked just fine
local outline = script:WaitForChild("Selection")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
mouse.Move:Connect(function()
local target = mouse.Target
for _,blocks in pairs(workspace.Blocks:GetChildren()) do
if target == blocks then
outline.Adornee = blocks
else
if (outline.Adornee == blocks) then
outline.Adornee = nil
end
end
end
end)
Maybe it doesn’t work with cloned parts? Or because the part name is random.
There is a script that randomizes the part name everytime it’s cloned, and I want it to select the cloned part.
Yeah in the game I’m using this in, there is a textbox that adds a part when I type “add”
It also uses HttpService to randomize the name of the part.
local HttpService = game:GetService("HttpService")
local id = HttpService:GenerateGUID(true)
partClone.Name = string.sub(id, 2, 8) --keeps string length short
Selections only render if they’re parented to workspace. When I personally work with selection options I just put them in the local camera and leave it at that
Forgot we’re working with Highlights that dont have this weird restriction
I would suggest instead of using Move, listen to changes to Target, you’ll send less events and improve performance since it will only fire when the target changes, and not when you move the mouse.
There’s some other tips I suggest like using IsDescendantOf instead of iterating over the children of the folder.