Hi. I’m trying to tween my leaves and trunk for trees.
Can anyone answer the following:
How can I retrieve all objects of a name, and tween all of them at the same time? Where would I place this script? I have models, and how would I tween these models? Can someone provide specific code examples?
Thanks!
-coolguyweir
You can use Instance:GetChildren() and Instance:GetDescendants(). They return an array of the objects. Instance:GetChildren() returns the array with the children objects directly under the Instance, whereas Instance:GetDescendants() return the array with the children objects, the children objects of the children objects, and so on. You can use it like this:
local Model = script.Parent
local Descendants = Model:GetDescendants()
for _,Object in pairs(Descendants) do
if Object.Name == "Leaf" then
-- Tween object
end
end
Thanks for the response! I’ll take this into consideration
hi! Also, for the code you showed, won’t the tween play one by one for each object? Like, play one tween, then stop it and play the next one? I want it to play to all models by the name of leaf at the same time.
After you play the tween starts playing it will keep going through the loop since it doesn’t need to wait for the tween to finish. Just try it, it should work.