Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you tween one object if you got all children?

Hello, I have a problem where once you touched one of the checkpoints, all the other checkpoints do the same tween. Once all the tweens play, you cannot activate it once more.

My question is:

How do you tween one object if you've got all children from a model or folder?

I have provided code:

for _, v in pairs(workspace.StagePoints:GetChildren()) do v.Touched:Connect(function(hit) if v ~= nil then if v.Parent == workspace.StagePoints then local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

			local parts = workspace.StagePoints:GetChildren()
			
			if player then
				if player.leaderstats.Stage.Value == tonumber(v.Name) - 1 then
					player.leaderstats.Stage.Value += 1
					player.TeleportedStage.Value = player.leaderstats.Stage.Value
					for i  = 1, #parts do
						local Tween = game.TweenService:Create(parts[i],TweenInfo.new(0.8,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Size = Vector3.new(6, 0.5, 6); Transparency = 1})
						local animatedPart = parts[i].Animated
						animatedPart.Transparency = 0
						Tween:Play() 
						wait(1.2)
						animatedPart.Size = Vector3.new(4, 0.25, 4)
					end
				end
			end
		end
	end
end)

end

I really need help with this because I've been trying to figure out how to do this for the past days.

2 answers

Wouldn't it be ideal to use WeldConstraints to weld said Model then use just tween the primary part? I mean, logically it would save a hell of a lot of tweening time as well as just a simpler method.

But if you'd rather use a for loop tween, be my guest. However I need to know what of errors/outputs you have throughout the code. Add some prints and find out where the code stops.

This is basically two answers so. As what opgeeza said: You can't use welds to tween an object. But you can use lerp As for NotBluxyl You could use the spawn function *(If you want the tween to play at the same time) * And for the pairs loop is correct You can learn the spawn function from here

This discussion is preserved as it was. New answers, comments, and votes are closed.