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

How to delete multiple instances of the same name with the same name parent?

Asked by 4 years ago

If I had many models called "Tree" in the workspace and in each tree I had an IntValue called "HP," how could I delete all of the IntValues parented to any models called "Tree?" If there are any models not called "Tree" with an IntValue then the IntValue should not be destroyed.

I need to know how to edit my game this way. I know how to script the logic for this problem, I just need to know how to to edit my place in studio cause the command prompt is only 1 line.

1 answer

Log in to vote
0
Answered by 4 years ago
for d,tree in pairs(game.Workspace:GetChildren() ) do
if tree.Name == "Tree" then
if tree:FindFirstChild("IntValue") then
local int = tree:FindFirstChild("IntValue")
int:Destroy()
end
end
end

what this does is that it checks all the first children in workspace and checks if they are called Tree and if it is called Tree then it looks after IntValue and if it can find the IntValue then it deletes the intValue

0
but how do i make it save in studio Phibonacci 37 — 4y
0
oh so u just want to delete them from studio, then i recomment just searching for intvalue in workspace and mark everyone thats under the tree and then just delete Gameplayer365247v2 1055 — 4y
0
Just put the code in the command bar MrOpScripter 81 — 4y
0
there isnt a line u can use in the command bar to do it, u just have to do it manually Gameplayer365247v2 1055 — 4y
Ad

Answer this question