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

How do I Delete a SelectionBox from a part that's in a Model?

Asked by 3 years ago

Hello, so I'm currently stuck on this part of the script where the selection box does not disappear when the mouse is not hovering over the grass. The grass parts are inside a model called "Plots." I've also tried to do for loop to look through the plots model but then I can't figure out how to find the selectionbox inside a grass part.

`local plots = game.Workspace:WaitForChild("Plots")
local value = script.Parent:FindFirstChild("SelectionValue")
local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

local box = Instance.new("SelectionBox")
box.Color3 = Color3.new(0, 255, 0)
box.LineThickness = 0.4

while wait(1) do
mouse.Move:connect(function()
    local target = mouse.Target
    if value and value.Value == true then
        if target.Name == "Grass" then
            box.Parent = target
            box.Adornee = target
        elseif target.Name ~= "Grass" then
            box.Adornee = nil
            box.Parent = nil
        end
    end
    end)
end`

Answer this question