Need Help with this Local Script

Hello There,

I am making a setting Screen Gui and I am Having a problem with Trying remove a Model when the Player clicks Remove Trees

If Someone Can tell me If My scripting is Wrong That Would Be helpful :slight_smile:
Here’s my Local script!

script.Parent.MouseButton1Down:Connect(function()

game.Workspace.Vegetation.Model.Transparency = 1


end)

  • Official_Simulation
    image

And Vegetation is a Folder that the Model is in.

  • Is game.Workspace.Vegetation.Model a model or a part?
  • Any errors from the output?

It is a game.Workspace.Vegetation.Model Model In the workspace.I haven’t checked Output yet.

Try this:

script.Parent.MouseButton1Down:Connect(function()
	for i, v in pairs(game.Workspace.Vegetation.Model:GetChildren()) do
		v.Transparency = 1
	end
end)

Ok I will try That and I will get back to you if It worked or not.

It Did Nothing Sorry, Is there anything I’m missing in My Script?

Please check for any errors in the Output and send them here.

1 Like

This is the Only Thing I’m getting.

Thanks! What kind of instance is Workspace.Vegetation.Model.Animated Tree? You can check what type of instance it is with “ClassName” in the Properties Tab.

image

It Is showing as a mesh part.
image_2022-05-11_131154136

Well, if you really want to destroy it rather than make it invisible, this would work.

script.Parent.MouseButton1Down:Connect(function()
	game.Workspace.Vegetation:ClearAllChildren() --Deletes all trees in folder
end)

Since you said it was a folder, why not delete all the trees in the folder?

2 Likes

That’s the ClassName for “Part”, which is not what I was looking for. Please try again with the instance that is called “Animated Tree”.

1 Like

workspace.Vegetation.Model:FindFirstChild(“Animated Tree”):ClearAllChildren()

The Class Name For Animated Tree is saying Model

try my script for the transparency part

Yes I should Of Done That Instead of making them invisible.

1 Like
script.Parent.MouseButton1Down:Connect(function()
	for i, v in pairs(game.Workspace.Vegetation.Model:GetChildren()) do
		v.Transparency = 1
	end

	for i, v in pairs(game.Workspace.Vegetation.Model["Animated Tree"]:GetChildren()) do
		v.Transparency = 1
	end
end)

If the above code snippet does not work, try this one below:

script.Parent.MouseButton1Down:Connect(function()
	for i, v in pairs(game.Workspace.Vegetation.Model:GetDescendants()) do
		v.Transparency = 1
	end
end)

Can you copy the script again or get rid of .Model?

script.Parent.MouseButton1Down:Connect(function()
	game.Workspace.Vegetation:ClearAllChildren() --Deletes all trees in folder
end)

It Worked But How do I make were the player Can click it again and they appear? Is that Possible.