My Tween is not playing

Hello. I know there are other posts about this but none helped.
So I have this Tween and for some reason it isn’t playing.
Here is the code:

            local TweenService = game:GetService("TweenService")
			local Van = game.Workspace.Van.VanBody

			local TWEEN_INFO = TweenInfo.new(5, Enum.EasingStyle.Sine, 
                        Enum.EasingDirection.Out, 0, true)
			local GOAL = {Position = Vector3.new(-34.534, 6.244, 23.164)}

			local LEAVE_TWEEN = TweenService:Create(Van, TWEEN_INFO, GOAL)

			LEAVE_TWEEN:Play()

Sorry for the trouble and thanks for the help!

do you get any errors in the output?

1 Like

There are no errors. What I don’t understand I was using this code a while ago then changed how I did something, copy and pasted the tween code and now it doesn’t work for some reason.
Sorry for the trouble.

It should work fine, can you add print statements before & after the Tween gets played?

It could just also be another issue if there’s an unexpected Weld in the Model itself

            local TweenService = game:GetService("TweenService")
			local Van = game.Workspace.Van.VanBody

			local TWEEN_INFO = TweenInfo.new(5, Enum.EasingStyle.Sine, 
                        Enum.EasingDirection.Out, 0, true)
			local GOAL = {Position = Vector3.new(-34.534, 6.244, 23.164)}

			local LEAVE_TWEEN = TweenService:Create(Van, TWEEN_INFO, GOAL)
            print("Tween Created, Not Played")
			LEAVE_TWEEN:Play()
            print("Tween Created, Now Playing")
2 Likes

There are welds in the model. Mabey that is messing with it?

Well, if you didn’t put those Welds inside manually I’d suggest temporary removing them and try again?

1 Like

I made them manually. Not with a script.

The only other option is to check your Output & see what got outputted back or not

If it printed both, then it does work but something’s preventing the Van Model from moving

If it printed only one, then there could potentially be some parameter you’re not exactly specifying?

1 Like

Mabey. I’ll try it soon. I can’t use my computer right now but I’ll try that when I can.
I’m pretty sure the parameters are correct because the code was working before I changed how I did the rest of the code.

Hello. Sorry I just now had the chance to test it out. What happened was:

Nothing.

Literally neither of the prints worked…
So sorry for the trouble.

        local TweenService = game:GetService("TweenService")
		local Van = game.Workspace.Van.VanBody

		local TWEEN_INFO = TweenInfo.new(5, Enum.EasingStyle.Sine, 
                    Enum.EasingDirection.Out, 0, true)
		local GOAL = {Position = Vector3.new(-34.534, 6.244, 23.164)}

		local LEAVE_TWEEN = TweenService:Create(Van, TWEEN_INFO, GOAL)

		LEAVE_TWEEN:Play()

Is that the full script or is there anything after or before ?

1 Like

There is stuff before and after. Here is the full script:

local seats = game.Workspace.Van.Seats
local teleportService = game:GetService("TeleportService")


local num = 0

local playersInSeats = {}

local countdown = false

-- remove the prints if you'd like

local function countDown()
	
	if not countdown then 
	
		countdown = true
		
		print("Start countdown")
		playersInSeats = {}
		
		for i = 5,1,-1 do -- change the first number to the length of countdown
			
			if num < 1 then break end -- if everyone gets off, reset timer
			if num == #seats:GetChildren() then break end -- if seats are full, teleport
			wait(1)
			
		end
		
		if num >= 1 then -- change this to minimum number of players
			
			print("Start game")
			
			local serverCode = teleportService:ReserveServer(6428301658) -- change game.PlaceId to the place id
			
			for _,seat in pairs(seats:GetChildren()) do
				
				if seat.Occupant then
					
					local plr = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent) -- occupant is the humanoid, hence why
					
					table.insert(playersInSeats,plr)
					
				end
				
			end
			
			for _,plr in pairs(playersInSeats) do -- can remove this if you like, it was to debug
				
				print(plr)
				
			end
			
			--game.ReplicatedStorage.TweenVan:Fire()
			
			local TweenService = game:GetService("TweenService")
			local Van = game.Workspace.Van.VanBody

			local TWEEN_INFO = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
			local GOAL = {Position = Vector3.new(-34.534, 6.244, 23.164)}

			local LEAVE_TWEEN = TweenService:Create(Van, TWEEN_INFO, GOAL)
			
			print("Tween Created: Not Played")
			LEAVE_TWEEN:Play()
			print("Tween is playing.")
			
			wait(4)
			
			teleportService:TeleportToPrivateServer(6428301658 ,serverCode, playersInSeats) -- change game.PlaceId to the place id
			
			countdown = false
			
		else
			
			countdown = false
			
		end
	
	end
	
end

for _,seat in pairs(seats:GetChildren()) do
	
	if seat:IsA("Seat") then
		
		seat:GetPropertyChangedSignal("Occupant"):connect(function()
			
			if seat.Occupant ~= nil then
				
				num = num + 1
				countDown()
				
			else
				
				num = num - 1
				
			end
			
		end)
		
	end
	
end

What this is doing is making it so that when a player sits in one of the seats in a van it starts a timer and everyone who is sitting in the van by the end of the timer gets teleported.

Can you put more prints like this:

local seats = game.Workspace.Van.Seats
local teleportService = game:GetService("TeleportService")


local num = 0

local playersInSeats = {}

local countdown = false

-- remove the prints if you'd like

local function countDown()
	if not countdown then 
	
		countdown = true
		
		print("Start countdown")
		playersInSeats = {}
		
		for i = 5,1,-1 do -- change the first number to the length of countdown
			
			if num < 1 then break end -- if everyone gets off, reset timer
			if num == #seats:GetChildren() then break end -- if seats are full, teleport
			wait(1)
			
		end
		
		if num >= 1 then -- change this to minimum number of players
			
			print("Start game")
			
			local serverCode = teleportService:ReserveServer(6428301658) -- change game.PlaceId to the place id
			
			for _,seat in pairs(seats:GetChildren()) do
				
				if seat.Occupant then
					
					local plr = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent) -- occupant is the humanoid, hence why
					
					table.insert(playersInSeats,plr)
					
				end
				
			end
			
			for _,plr in pairs(playersInSeats) do -- can remove this if you like, it was to debug
				
				print(plr)
				
			end
			
			--game.ReplicatedStorage.TweenVan:Fire()
			
			local TweenService = game:GetService("TweenService")
			local Van = game.Workspace.Van.VanBody

			local TWEEN_INFO = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
			local GOAL = {Position = Vector3.new(-34.534, 6.244, 23.164)}

			local LEAVE_TWEEN = TweenService:Create(Van, TWEEN_INFO, GOAL)
			
			print("Tween Created: Not Played")
			LEAVE_TWEEN:Play()
			print("Tween is playing.")
			
			wait(4)
			
			teleportService:TeleportToPrivateServer(6428301658 ,serverCode, playersInSeats) -- change game.PlaceId to the place id
			
			countdown = false
			
		else
			
			countdown = false
			
		end
	
	end
	
end

for _,seat in pairs(seats:GetChildren()) do
	
	if seat:IsA("Seat") then
		
		seat:GetPropertyChangedSignal("Occupant"):connect(function()
			
			if seat.Occupant ~= nil then
				print("Someone in the car, starting timer")

				num = num + 1
				countDown()
				
			else
				
				num = num - 1
				print("No one detected")
			end
			
		end)
		
	end
	
end

and then show the output of the code ?

1 Like

Here you go:

image

The 404 error is normal. It’s because of the teleport.

The 403 error is probably stopping the rest of the script from working. You should try putting the not working code in comments.

1 Like

I’ll try commenting out the teleport when I get the chance. Thanks!

1 Like

The 403 occurs when you try to reserve a server with API service / HttpRequests disabled, you should enable these in game settings and try again.

They are enabled. And that isn’t what im trying to fix. Sorry.

Hello. I just tested it and it is working now! Thanks! Now the only problem is getting the seats to move with the van.

Thank you so much for the help! :slightly_smiling_face:

1 Like