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

How to delete a part using a value?

Asked by 4 years ago

If the value for lastbrickspawned was brick288. Then it would have destroyed brick288 in workspace.

local bricktodelete = script.Parent.Parent.Parent.BottomBar.Models.LastBrickSpawned.Value
script.Parent.MouseButton1Down:Connect(function()
    workspace.bricktodelete:Destroy()
end)
0
Remove workspace when deleting the part, maybe that helps. Soban06 410 — 4y
0
why to remove the workspace, is it even possible? dionsyran2 66 — 4y
0
Do `workspace[bricktodelete]:Destroy()` Spjureeedd 385 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You would use an if statement to see if the condition is met. In this case, if the value is equal to 'x', delete the brick.

local brick = game.Workspace.Your_Brick
local bricktodelete = script.Parent.Parent.Parent.BottomBar.Models.LastBrickSpawned.Value

script.Parent.MouseButton1Down:Connect(function()
    if bricktodelete == "brick288" then
        brick:Destroy()
    end
end)

Ad

Answer this question