Trying to make a function where when you put in a place id for a textbox, it teleports you to that desired place. But I’m getting this error that says Unable to cast Instance to int64. Here’s the code for the serverscript:
local TeleportService = game:GetService("TeleportService")
local playerList = game.Players:GetPlayers()
game.ReplicatedStorage.TeleportPlayer.OnServerEvent:Connect(function(placeID) --This is an argument that defines the text box
local PlaceId = placeID
TeleportService:TeleportPartyAsync(PlaceId, playerList)
print("Teleporting...")
end)
The script for the local script inside of the gui:
Don’t forget that when firing a RemoteEvent from a client, there is always a Player parameter that is attached to it! I think the function is trying to use the player instance as the place id.
Funnily enough, it seems like that solution is a part of an old thread you made. Just move the playerlist variable inside the function, and it should work.
Just loop trough all the players and call teleport on them. TeleportPartyAsync will try to put them in the same server, so unless you need them to be in the same server use Teleport.
And remember, remoteevent events always pass in a player parameter, so you need to receive it like function (player, data) end
I’m trying to make a function that when you put a game id into a textbox and then press the button to fire the server, it teleports everyone in the server to the game.
And why would it be asking for a universeid? Just call TeleportPartyAsync(placeId, players) with placeId as a number and players as a table of players in your game. Make sure to wrap it in a pcall as it can error.
Ah, I forgot to mention earlier that TeleportPartyAsync only works within the same game. Perhaps Teleport is a better option, though you’d have to iterate through all the players in the playerlist.
Ah, you can’t teleport cross-game with that. The place you teleport to has to be a part of your game. You have to call Teleport for each player in the game like NINJA said.
Ok I managed to get it working with for looping the normal Teleport function. Thanks for your guys help and teaching me a bit more about TeleportServices!