Why doesn't this teleportation script actually teleport me?

  1. What do you want to achieve?

I want to make it so that when the part that is touched (otherPart) it will teleport me to another server of my game that is part of my previous game in the game explorer. However, when I log the game on actual Roblox, not studio, the teleportation simply doesn’t work and I’m not sure why.

  1. What is the issue?

Teleportation isn’t working correctly, I have no idea where the issue lies. The script that is below is placed in a local script with the parent being the part that is being touched, this is anchored and is not touching anything such as the floor.

Local script code

local TeleportService = game:GetService("TeleportService")
local typeServer = 4767149057
local function onPartTouch(otherPart)
	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if player then
		TeleportService:Teleport(typeServer, player)


(This has been done in a server script)

1 Like

Okay, for some reason this script now works. I have no idea why it’s suddenly decided to work, sorry for those (if anyone) who attempted to solve my problem.

Great to hear you solved your issue, just remember to mark your issue solved! :slightly_smiling_face:

Just a quick tip - I noticed that you used game.Players on line 5 of your script.
Although this probably will work, it is best practice to use :GetService() instead. (game:GetService("Players"))
:GetService() is best because:

  1. It will add the service if it doesn’t already exist. (such as Teams)
  2. It will still work if the service isn’t loaded at the time the line is executed.
  3. You are able to “rename” the services (by assigning them to a variable), allowing you to quickly access services that have long names more than once in a script.

Remember - :GetService() over game.Service!