for i,v in ipairs(game.Players:GetPlayers()) do
if target == tostring(v.UserId) then
print("teleporting")
local code = tostring(CodeID)
TS:TeleportToPrivateServer(game.PlaceId,code,v)
end
end
i get unable to cast values to object error and when i use
for i,v in ipairs(game.Players:GetPlayers()) do
if target == tostring(v.UserId) then
print("teleporting")
local code = tostring(CodeID)
local players = game.Players:GetPlayers()
TS:TeleportToPrivateServer(game.PlaceId,code,players)
end
end
i get error 769 and it fails from teleporting the player
all i want to is to teleport a single player to a specfic reserved server but it gives me that unable to cast values to object error and when i make it get all the players in the server and teleport them it gives me error 769
for i,v in ipairs(game.Players:GetPlayers()) do
if target == tostring(v.UserId) then
print("teleporting")
local code = tostring(CodeID)
TS:TeleportToPrivateServer(game.PlaceId,code,{v})
end
end
that was a good solution for the issue of teleporting a single player but im still having the error 769 issue that prevents me from teleporting do you know a solution for it
this would probably because you are trying to teleport them with a string. Use ReserveServer()
for i,v in ipairs(game.Players:GetPlayers()) do
if target == tostring(v.UserId) then
print("teleporting")
local code = TS:ReserveServer(CodeID)
TS:TeleportToPrivateServer(game.PlaceId,code,{v})
end
end
all i tried to is to send the code from the reserved server to another one (each one has 1 player) and when i press a button its supposed to teleport the player from the other server to the current server im in using the code i tried using the code normally still the same issue
this sends from a client to server and then sends the values in a messaging service
request.OnServerEvent:Connect(function(player, Target)
local value = Target..game.PrivateServerId..string.len(Target)
player.Character.Config.Requests.IsAccepting.Value = true
print(game.PrivateServerId)
MessagingService:PublishAsync(Topic2,value)
end)
MessagingService:SubscribeAsync(Topic2, function(Message)
print("detected")
if player.Character.Config.Requests.IsAccepting.Value == false then
local value = Message.Data
local lastdigit = value:sub(#value, #value) -- detects how many characters is the player so it can differenciate between the code and player
local TargetID = value:sub(1, lastdigit) -- detects the player
local CodeID = value:sub(lastdigit + 1, #value - 1) -- detects the code
local target = tostring(TargetID)
print(CodeID)
for i,v in ipairs(game.Players:GetPlayers()) do
if target == tostring(v.UserId) then
local players = game.Players:GetPlayers()
print("teleporting")
TS:TeleportToPrivateServer(game.PlaceId,CodeID,{v})
--TS:TeleportToPrivateServer(game.PlaceId,code,players)
end
end
end
end)```
MessagingService:SubscribeAsync(Topic2, function(Message)
print("detected")
if player.Character.Config.Requests.IsAccepting.Value == false then
local value = Message.Data
local lastdigit = value:sub(#value, #value) -- detects how many characters is the player so it can differenciate between the code and player
local TargetID = value:sub(1, lastdigit) -- detects the player
local CodeID = value:sub(lastdigit + 1, #value - 1) -- detects the code
local target = tostring(TargetID)
print(CodeID)
for i,v in ipairs(game.Players:GetPlayers()) do
if target == tostring(v.UserId) then
local players = game.Players:GetPlayers()
print("teleporting")
local code = TS:ReserveServer(game.PlaceId) --this will be the reserved server code
TS:TeleportToPrivateServer(game.PlaceId,code,{v})
--TS:TeleportToPrivateServer(game.PlaceId,code,players)
end
end
end
end)
local TPService = game:GetService("TeleportService") -- Get the TP service
local Target = 0 -- UserId of the player you want to TP, leave as 0 if you want to TP everyone
function Teleport() -- This function can be called at any time
local TPCode = TPService:ReserveServer(game.GameId) -- This can also be changed to an existing server code
local PlrsToTP = {}
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Player.UserId == Target or Target == 0 then
table.insert(PlrsToTP,#PlrsToTP+1,Player) -- Insert player to TP into TP table
end
end
TPService:TeleportToPrivateServer(game.GameId,TPCode,PlrsToTP) -- Teleport
end
This solution will teleport players that are selected to new ReservedServer each, since you have the :ReserveServer() in a for loop. Just remove it from the loop and it should be okay.