Trying to + a tween

Title may not be explanitory, but i will explain.

I want the script to add/tween a objects postion by adding it.

But, the code i made isnt working.

Code -

local tween = game:GetService("TweenService")

local goal = {}

goal.Position = goal.Position + Vector3.new(12,12,12)- -the bit the error genorates.+


local tweenifo = TweenInfo.new(
		2, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		true, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
)


local tw = tween:Create(script.Parent,tweenifo,goal)

tw:Play()

Thanks for any help!

Error -

Workspace.Bone.Bone.Script:5: invalid argument #1 (Vector3 expected, got nil)]

Goal is a table, not a class with the member of Position
Read about tables here: Tables | Documentation - Roblox Creator Hub

local tween = game:GetService("TweenService")

local goal = {}

goal.Position = script.Parent.Position + Vector3.new(12,12,12)- -the bit the error genorates.+


local tweenifo = TweenInfo.new(
		2, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		true, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
)


local tw = tween:Create(script.Parent,tweenifo,goal.Position)

tw:Play()

Unable to cast to dictonary, ive never seen this error before.

Change

local tw = tween:Create(script.Parent,tweenifo,goal.Position)

To:

local tw = tween:Create(script.Parent,tweenifo,goal)

Here is the updated script:

local tween = game:GetService("TweenService")

local tweenifo = TweenInfo.new(
		2, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		true, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
)


local tw = tween:Create(script.Parent,tweenifo, {script.Parent.Position + Vector3.new(12,12,12)})

tw:Play()
1 Like