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.

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

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

1 Like

Try this:

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

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

1 Like

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

1 Like

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

2 Likes

This is the Only Thing I’m getting.

1 Like

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

1 Like

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

1 Like

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?

3 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”.

2 Likes

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

1 Like

The Class Name For Animated Tree is saying Model

1 Like

try my script for the transparency part

1 Like

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

2 Likes
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)
1 Like

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)
1 Like

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

1 Like