Help on game:BindToClose()

Hello and I’m making a system that whenever my game shut down all players will be teleported into another server but it seems it’s not working properly.

Script:

local TweenService = game:GetService("TweenService")
local TeleportService = game:GetService("TeleportService")

local gameId = --GameId (I was typing this manually, i'm not in studio rn but I have the Game Id)

local updateMessage = script.Parent
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)

local fadeTween = TweenService:Create(updateMessage, tweenInfo, {BackgroundTransparency = 0}

game:BindToClose(function()
      local reservedServer = TeleportService:ReserveServer(GameId)
      fadeTween:Play()
      TeleportService:Teleport(reservedServer, GameId)
end)

I think you messed your variable names on reserved:Server/Service

game:BindToClose(function()
      local reservedServer = TeleportService:ReserveServer(GameId)
      fadeTween:Play()
      TeleportService:Teleport(reservedService, GameId)
end)

no I think that’s not the problem sorry for that, I was typing all this code manually cuz I’m not in studio rn

Maybe this will help.

1 Like