The issue: On the teleport result specifically on the second argument on teleport async I tried countless times to get the player but I couldn’t.
I’ve tried to change it to the humanoid and getting the children of game.Players and as well as using game.Players:GetPlayers() but only one thing works which is that I need to say specifically who is getting teleported for instance this would work: game.Players.wesam1992 and I’d get teleported but only those who I put their names in the script and the script would teleport them
It is a Server-side script.
local players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local TeleportService = game:GetService("TeleportService")
local ServerAccessCodes = DataStoreService:GetDataStore("ReservedServerAccessCodes")
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true
game.Players.PlayerAdded:Connect(function(Player)
-- problem ⬇
local teleportResult = TeleportService:TeleportAsync(8117862651, {Player.Name}, teleportOptions)
ServerAccessCodes:SetAsync(teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode)
local accssCode = game.PrivateServerId ~= "" and ServerAccessCodes:GetAsync(game.PrivateServerId)
print ("tp ran")
Well, but What are they referencing the player as? Local player or a function etc? I tried to print the Player to see what it would give but It wasn’t printing it meaning that there is an error in the code itself. I’ll go debug it and come back.
local DataStoreService = game:GetService(“DataStoreService”)
local TeleportService = game:GetService(“TeleportService”)
local ServerAccessCodes = DataStoreService:GetDataStore(“ReservedServerAccessCodes”)
local teleportOptions = Instance.new(“TeleportOptions”)
local PlaceId = “8117862651”
teleportOptions.ShouldReserveServer = true
game.Players.PlayerAdded:Connect(function(Player)
print(PlaceId,Player,teleportOptions)
local teleportResult = TeleportService:TeleportAsync(PlaceId, Player.Name, teleportOptions)