Tween service not working?

Im trying to tweet a part to the position of another part, but its not working, any clue as to where i went wrong?

local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals =
	{

		Position = g1.Position == game.Workspace.OutfitCon.MidPart.Position
	}

local tween = TweenService:Create(g1,Info,Goals)
1 Like

You don’t need to add the g1.Position == part in there. Change it to this:

local Goals =
	{

		Position = game.Workspace.OutfitCon.MidPart.Position
	}

its now saying attempt to call a instance value when I do the tween?

It should work with this script:

Do not forget to use the TweenService with game:GetService and you should not do Position == g1.Position =… because you already mentioned the Position. Make sure Position isnt written wrong. And instead of == use = in the goal.

local TweenService = game:GetService("TweenService")

local g1 = game.Workspace -- add your part here

local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals = {
	
		Position = game.Workspace.OutfitCon.MidPart.Position
	}

local tween = TweenService:Create(g1,Info,Goals)
tween:Play()

tell me if its not working

It didnt work, heres the full script, maybe im missing something?

local lol = "e"

local g1 = game.Workspace.OutfitCon.Group1.Part
local g2 = game.Workspace.OutfitCon.Group2.Part

local dog = false

local TweenService = game:GetService("TweenService")


--send g1 to mid
local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals =
	{

		Position = g1.Position +  Vector3.new(0,0,20);
	}

local tween = TweenService:Create(g1,Info,Goals) 

-- send g1 to end

local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals =
	{

		Position = g1.Position +  Vector3.new(0,0,20);
	}

local tween2 = TweenService:Create(g1,Info,Goals) 

--send g2 to mid
local TweenService = game:GetService("TweenService")

local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals =
	{

		Position = g2.Position + Vector3.new(0,0,20);
	}

local tween3 = TweenService:Create(g2,Info,Goals) 

-- send g2 to end
local TweenService = game:GetService("TweenService")

local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals =
	{

		Position = g2.Position + Vector3.new(0,0,20);
	}

local tween4 = TweenService:Create(g2,Info,Goals) 

while true do
	if lol == "e" and dog == false then
		dog = true
		g1.Position = game.Workspace.OutfitCon.StartPart.Position
		wait()
		tween() --- ERROR
		wait()
		wait(10)
		tween2()
		wait(1)
		lol = "f"
		dog = false
	else
		if lol == "f" and dog == false then
			dog = true
			g2.Position = game.Workspace.OutfitCon.StartPart.Position
			wait()
			tween3()
			wait()
			wait(10)
			tween4()
			wait(1)
			lol = "e"
		dog = false
		end
	end
end

I guess one of the errors was that you mentioned TweenService 3 times in this script only write this once on the top of the script:

local TweenService = game:GetService("TweenService") -- only write this once in your script!

I am not sure if it works now but I improved it. Probably the error was that you used the same names like Info and Goals 4 times in all tweens.

Also its better to use task.wait() instead of wait() in your scripts because task.wait() is the improved version and its better.

heres the full script:

local TweenService = game:GetService("TweenService")
local lol = "e"
local g1 = game.Workspace.OutfitCon.Group1.Part
local g2 = game.Workspace.OutfitCon.Group2.Part
local Debounce = false
--send g1 to mid
local Info = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals =
	{
		Position = Vector3.new(0,0,20);
	}

local tween = TweenService:Create(g1,Info,Goals) 
-- send g1 to end
local Info2 = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals2 =
	{
		Position = g1.Position +  Vector3.new(0,0,20);
	}

local tween2 = TweenService:Create(g1,Info2,Goals2) 
--send g2 to mid
local Info3 = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals3 =
	{
		Position = g2.Position + Vector3.new(0,0,20);
	}

local tween3 = TweenService:Create(g2,Info3,Goals3) 
-- send g2 to end
local Info4 = TweenInfo.new(
	2,                             -- Length
	Enum.EasingStyle.Linear,      -- Easing Style
	Enum.EasingDirection.Out,      -- Easing Direction
	0,                             -- Times repeated
	false,                          -- Delay
	0
)

local Goals4 =
	{
		Position = Vector3.new(0,0,20);
	}

local tween4 = TweenService:Create(g2,Info4,Goals4) 

while true do
	if lol == "e" and Debounce == false then
		Debounce = true
		g1.Position = game.Workspace.OutfitCon.StartPart.Position
		task.wait()
		tween() --- ERROR
		task.wait(10)
		tween2()
		task.wait(1)
		lol = "f"
		Debounce = false
	else
		if lol == "f" and Debounce == false then
			Debounce = true
			g2.Position = game.Workspace.OutfitCon.StartPart.Position
			task.wait()
			tween3()
			task.wait(10)
			tween4()
			task.wait(1)
			lol = "e"
			Debounce = false
		end
	end
end

sadly still giving that error, I truly have no idea why.

can you tell me what the error says?

Attempt to call a instance value, on the line where I call the first tween()

You need to replace where it says tween(), tween2() etc with tween:Play() and tween2:Play() because you are calling the tweens which are an instance.

You are basically doing workspace() which is giving the error

1 Like

oh wait your actually right I didnt notice that xd

Also remember these things:

  • Only mention a Service once on the top of a script.
  • its better to use task.wait() than wait()
  • if you use multiple tweens make sure you call the second tweens stuff Goals2 and Info2 or whatever you like so the script wont give you an error that theres multiple things called Goals and Info
  • and how dandcx mentioned dont forget the :play() command. Didnt notice that sry