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")
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.
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.
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