Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to delete a part using a value?

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)

3 comments

0

Remove workspace when deleting the part, maybe that helps.

0

why to remove the workspace, is it even possible?

0

Do workspace[bricktodelete]:Destroy()

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.