Teleporter to place wont work

Hey,

I made a teleport script that teleports you to another place, however it doesn’t seem to work. I have tried numerous solutions but none seem to work. Can you help?

local TeleportService = game:GetService("TeleportService")
local PlaceID = 4627919349

script.Parent.Touched:Connect(function(hit)
	wait(0.1)
	local player = game.Players.GetPlayerFromCharacter(hit.Parent)
	if player then
		TeleportService:Teleport(PlaceID, player)
	end
end
2 Likes

Do you have third party teleports enabled?

I do have third party teleports enabled.

Hi there,

There were a few things wrong in your code, let me point them out for you.

For starters, when using GetPlayerFromCharacter, you need to use ‘’:‘’ not “.”

So it would look more like this ; game.Players:GetPlayerFromCharacter(hit.parent)

Secondly you forgot a “)” to close your final end.

Lastly, you should definitely add debounce so you don’t get spammed with errors in your output when one teleport request is already being processed.
The corrected code would look like this :

local TeleportService = game:GetService("TeleportService")
local PlaceID = 4627919349
local db = false

script.Parent.Touched:Connect(function(hit)
	wait(0.1)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player and not db then
		db = true
		TeleportService:Teleport(PlaceID, player)
		wait(5)
		db = false
	end
end)
2 Likes

It worked! Thank you so much…

1 Like