You probably want to teleport the player on a server script instead. To do that, you want to have a RemoteEvent in this situation. In your LocalScript, you want to fire the remote event when a player clicks/taps on the button, by using the function FireServer(). Then you do the teleport stuff on a server script by first calling the OnServerEvent function.
Confirm that you have the correct Place Id. Otherwise it may not work at all. And also, the game you want players to teleport MUST be your game, or else it will not allow you to join that place at any given cost.
local TeleportEvent = game.ReplicatedStorage.Teleport
local Teleport = game:GetService("TeleportService")
local GameID = 7256016202
local Players = game.Players.LocalPlayer
TeleportEvent.OnServerEvent:Connect(function()
Teleport:Teleport(GameID, Players)
end)
You cant access the local player on a server script. That can only be accessed on a LocalScript.
To get the actual player who clicked/tapped on the button, you just want to add player or something in the paranthesis in the OnServerEvent as the first argument.
Use this code for your server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teleport = game:GetService("TeleportService")
local TeleportEvent = ReplicatedStorage:WaitForChild("Teleport")
local GameID = 7256016202
TeleportEvent.OnServerEvent:Connect(function(plr)
Teleport:Teleport(GameID, plr)
end)
There’s no need for a RemoteEvent if you’re teleporting the LocalPlayer in the LocalScript. Check if teleporting players to third-party games in the game settings is enabled.
If the placeId is certainly correct, and you have implemented any other scripts or models, check if they’re interfering with this.
I think I found the issue.
Try using this code for your server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService") -- Renamed variable to 'TeleportService', cuz the problem was that you put 'Teleport' as the variable name, and thats the exact name for the "Teleport" function
local TeleportEvent = ReplicatedStorage:WaitForChild("Teleport")
local GameID = 7256016202
TeleportEvent.OnServerEvent:Connect(function(plr)
TeleportService:Teleport(GameID, plr) -- teleports player who clicked/tapped the button
end)
The problem is that you named the TeleportService the same as the Teleport function. Try name your game:GetService(“Teleport Service”) something else but not Teleport. You can name it TeleportService
@FunnelDeveloper I think you should mark my first post as the solution. This wasnt really a big problem, but I believe the first post I made in this topic has more to it.