Help with TweenService

So I’m working on a map right now, and I’m trying to do spears that go up and down using the while true do function. But it says:

image

Here’s the script:

-- Spear --

-- Local Variables --
local TweenService = game:GetService("TweenService")
local Spears = workspace.Spear:GetChildren()

-- Properties (Tween1) --

local TweenProperties1 = TweenInfo.new(
	
	1,
	Enum.EasingStyle.Quart,
	Enum.EasingDirection.Out,
	0,
	false,
	0
	
)

local SpearProperties1 = {
	
	Position = Spears.Position + Vector3.new(0, -20, 0)
	
}

local Tween1 = TweenService:Create(TweenProperties1, SpearProperties1, Spears)

-- Properties (Tween2) --

local TweenProperties2 = TweenInfo.new(
	
	1,
	Enum.EasingStyle.Quart,
	Enum.EasingDirection.Out,
	0,
	false,
	0
	
)

local SpearProperties2 = {
	
	Position = Spears.Position + Vector3.new(0, 20, 0)
}

local Tween2 = TweenService:Create(TweenProperties2, SpearProperties2, Spears)
-- Function --

while true do
	
	Tween1:Play()
	wait(1)
	
	Tween2:PLay()
	wait(1)
end

My theorized answer is for i, v in pairs (workspace.Spears:GetChildren()), but I don’t know how.

Seperating names between different parts will waste a lot of work.

Questions:

  • How do I make this work?
  • Are there other methods on executing code on multiple parts with the same name?

The first argument in tweenService:Create should be an instance, not a table.

1 Like

I am confused a bit, can you elaborate?

Switch TweenProperties2 and Spears.

1 Like

It worked now! Thank you!

I’ll just fix the values since it goes too far.

1 Like