Turn off shadows(castshadow) for all objects named: "Tree 1"

Title explains it all. How would I do this? The only reason I want a script for this is because I have way too many trees to select, and if I do. My studio will crash. So pretty much a script to run in command bar.(To prevent lag)

for i, tree in pairs(game.Workspace:GetDescendants()) do

    if tree.Name == "Tree 1" then

        tree.CastShadow = false

    end

end

image
won’t work.
Theres the actual parts inside
Russian Part:
Листья

I’m writing this on mobile so I can’t directly check, but I’m pretty sure that there’s a plugin called ‘part picker’ that you could use.

It’s useful for selecting many similar parts.

You could also have a script like the reply above, however.

Edit: in the script, you can add another for,I,v loop that goes through the model

Cant find a plugin named “Part Picker”

for i, tree in pairs(game.Workspace:GetDescendants()) do
    if tree.Name == "Tree 1" then
		for i,v in ipairs(tree:GetDescendants) do
			if v:IsA("BasePart") then
        		v.CastShadow = false
			end
		end
    end
end

image

for i, tree in pairs(game.Workspace:GetDescendants()) do
    if tree.Name == "Tree 1" then
		for i,v in ipairs(tree:GetDescendants()) do
			if v:IsA("BasePart") then
        		v.CastShadow = false
			end
		end
    end
end

Sorry I forgot to add brackets

Thanks so much! You saved my life!

1 Like

You dont need pairs or ipairs anymore, you just need to do for example for k, v in <table> do

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.