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

How could i delete a Model using a script?

local ClickDetector = workspace.Part.ClickDetector

function buildapole ()
	local lowpart = Instance.new("Part") -- Getting the lowest part
	lowpart.Parent = game.Workspace
	lowpart.Position = Vector3.new(4 , 0.5 , 0)
	lowpart.Size = Vector3.new(6 , 1 , 6)
	lowpart.Anchored = true
	lowpart.Material = Enum.Material.Wood
	lowpart.BrickColor = BrickColor.new("Brown")
	
	local midpart = Instance.new("Part") -- Getting the Cylinder
	midpart.Parent = game.Workspace
	midpart.Position = Vector3.new(4, 5.5, 0)
	midpart.Size = Vector3.new(12, 7, 3)
	midpart.Anchored = true
	midpart.Material = Enum.Material.Wood
	midpart.BrickColor = BrickColor.new("Brown")
	midpart.Shape = Enum.PartType.Cylinder
	midpart.Orientation = Vector3.new(0 , 0 , 90) -- Rotate 90 Degrees
	
	
	local ballpart = Instance.new("Part") -- Getting the Sphere
	ballpart.Parent = game.Workspace
	ballpart.Anchored = true
	ballpart.Position = Vector3.new(4, 13.5, 0)
	ballpart.Shape = Enum.PartType.Ball
	ballpart.Size = Vector3.new(7, 7, 7)
	ballpart.Material = Enum.Material.Neon
	ballpart.Color = Color3.new(1, 0.980392, 0.384314)
	
	local Polemodel = Instance.new("Model")
	Polemodel.Parent = game.Workspace
	Polemodel.Name = "PoleModel"
	lowpart.Parent = game.Workspace.PoleModel
	midpart.Parent = game.Workspace.PoleModel
	ballpart.Parent = game.Workspace.PoleModel
	
	
end
ClickDetector.MouseClick:connect(buildapole)

i created a light Pole and Grouped them in a Model

i tried to use script on the DevForum to delete the Model Group through Click Detector on a Part

Can somebody give me a script that could destroy it on Click with a Part?

Thank Everyone

1 answer

✓ Accepted answer

you could simple use model:Destroy()

ClickDetector.MouseClick:connect(function(plr)
-- it might have some typos because i wrote it directly by this website
-- insert the rest of the code here

thepathtowhatyouwanttodelete:Destroy() -- as said, the path of the thing you want to delete
end)

2 comments

0

hm, but im looking to delete it with another part

0

Oh! nvm, i got it now thanks btw. Have a good day!

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