You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Make the loop shown below run a
local tweenService = game:GetService("TweenService")
local growtime = 20
local maxheight = math.random(3,7)
for i, v in pairs(script.Parent:GetChildren()) do
if v.Name == "Part" then
task.wait(math.random(0.2,0.7))
local tweenInfo = TweenInfo.new(growtime, Enum.EasingStyle.Linear)
local goal = {Size = Vector3.new(0.125, maxheight, 0.125)}
local tween = tweenService:Create(v, tweenInfo, goal)
tween:Play()
end
end
I tried adding a print after the second to last end hoping it would only run once they were all finished but It ran every time.
local tweenService = game:GetService("TweenService")
local growtime = 20
local maxheight = math.random(3,7)
for i, v in pairs(script.Parent:GetChildren()) do
if v.Name == "Part" then
task.wait(math.random(0.2,0.7))
local tweenInfo = TweenInfo.new(growtime, Enum.EasingStyle.Linear)
local goal = {Size = Vector3.new(0.125, maxheight, 0.125)}
local tween = tweenService:Create(v, tweenInfo, goal)
tween:Play()
tween.Completed:Wait()
--BOOL
end
end
You need to use Tween.Completed
In this case, the script will wait until tween is finished
If you need this cycle to continue you can use
This causes the loop to pause between tweening each part, I need the parts to all tween at the same time. The script is growing wheat, and its made up of parts and I need the player to be able to harvest the crop after all of the parts grow
local tweenService = game:GetService("TweenService")
local growtime = 20
local maxheight = math.random(3,7)
for i, v in pairs(script.Parent:GetChildren()) do
if v.Name == "Part" then
task.wait(math.random(0.2,0.7))
local tweenInfo = TweenInfo.new(growtime, Enum.EasingStyle.Linear)
local goal = {Size = Vector3.new(0.125, maxheight, 0.125)}
local tween = tweenService:Create(v, tweenInfo, goal)
tween:Play()
tween.Completed:Connect(function()
--BOOL
end)
end
end