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

How could i delete a Model using a script?

Asked by 3 years ago
Edited 3 years ago
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

Log in to vote
1
Answered by 3 years ago

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)
0
hm, but im looking to delete it with another part Bllakex335zzGRiff 5 — 3y
0
Oh! nvm, i got it now thanks btw. Have a good day! Bllakex335zzGRiff 5 — 3y
Ad

Answer this question