TweenService:Create no property named 'Position' for object 'OriginalPosition'

#1

Okay, so I’m working on some sort of script that moves a table of models up above the sky.
I’m storing the OriginalPosition and SkyPosition inside these crates.
This is my code:

local Crates = workspace.Crates
	for _, crate in next, Crates:GetChildren() do
		
		local a = Instance.new("Vector3Value", crate)
		a.Name = "OriginalPosition"
		a.Value = crate.Center.Position
		
		local b = Instance.new('Vector3Value', crate)
		b.Name = "SkyPosition"
		b.Value = crate.Center.Position + Vector3.new(0, 250, 0)
		
		for _, cratePart in next, crate:GetChildren() do
			local pos  = {}
			pos.Position = b.Value
			
			local New = TweenService:Create(cratePart, TweenInfo.new(13), pos)
			New:Play()
		end
	end

If anyone knows what is causing this error to happen and how I can fix it that’d be hugely appreciated.

0 Likes

#2

You aren’t checking the ClassName of the children you’re iterating through and confirming they’re BaseParts.

for _, cratePart in next, crate:GetChildren() do

This here, you’re iterating through the children of the crate. The Vector3Values you created are children of the crate, therefore they’re also included in the loop. Vector3Values don’t have a Position property.

On a separate note, you should get into the habit of setting the properties first before the parent.

2 Likes

#3

Thank you, I’m struggling to notice these small issues.

0 Likes