Teleport to other game script has an error

this script should teleport me to a different game when i touch the part but it doesnt do that exact thing, why?

local TeleportService = game:GetService("TeleportService")

local Place = (game id)



script.Parent.Touched:connect(function(hit)

	local player = game.Players:GetPlayerFromCharacter(hit.Parent)

	if player then

		TeleportService:Teleport(Place, player)

	end

end)

I think i’d be preferable to have a check to see if hit.Parent is indeed a character or not another object.

local TeleportService = game:GetService("TeleportService")
local Place = (game id)

script.Parent.Touched:connect(function(hit)
    if hit.Parent:WaitForChild("Humanoid") then
	    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	    if player then
		    TeleportService:Teleport(Place, player)
	    end
    end
end)

same error, here

https://gyazo.com/6f383ea60d3f47b96060d8cd761ad162

This isn’t a good idea, If it doesn’t exist, it yields forever, use:

if part:FindFirstChildOfClass("Humanoid") then
--// code
end
1 Like

Weird. Can you show the Developer Console’s output? (F9)

Maybe third party teleports isn’t enabled?

i added what u said and now theres no error but it doesnt teleport me at all.

local TeleportService = game:GetService("TeleportService")
local Place = (game id)
local part = script.Parent

script.Parent.Touched:connect(function(hit)
	if part:FindFirstChildOfClass("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player then
			TeleportService:Teleport(Place, player)
		end
	end
end)

only thing i see is this
image

That’s a demonstration. I didn’t realize you had a variable called part.

oh i added the variable because i thought u were reffering to the part that had to be touched

Change part to hit is probably what they mean.

1 Like

Change this to

if hit.Parent:FindFirstChildOfClass("Humanoid") then
1 Like

now i get this
image
im feeling really dumb, theres so much more for me to learn

It’s alright. I think that’s ROBLOX being faulty, not sure.

Is there a workaround? this is a pretty important script for my game. (its a hub leading to all of my other games)

1 Like

I don’t really know. Maybe someone else would, but I don’t know anything that could be useful.

1 Like

Is there anything in the console that is of relevant information?

1 Like

yes! i found it, how do i enable third party teleports?

1 Like

Game settings (CharLimitAAAAAAAAAAAAAAA)

1 Like

Game Settings → Security
characters

1 Like