I'm trying to make teleporters in my active start place to teleport to an inactive place in the same game. I don't fully understand the sub-places of a game, but I'm assuming that they are the "Other Places" in a game. I've tried the sample code from the Wiki, but it doesn't seem to be working. I don't have a lot of experience with teleporting between places.
This is code inside of a touch button:
function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then game:GetService("TeleportService"):Teleport(224906765, player) -- 224906765 is place id end end script.Parent.Touched:connect(onTouched)
script.Parent.Touched:connect(function(p) local player = touched.FindFirstChild("Humanoid").Parent if player then game:GetService("TeleportService"):Teleport(224906765, player) end end
I think your mistake was that you didn't properly define player. I've done my best to help, but I don't quite know how to explain.
Just a heads up, you can shorten scripts like So say if you had.
function onClick() --Code here end script.Parent.MouseClick:connect(onClick)
You could change it to
script.Parent.MouseClick:connect(function() --Code here end)
So, you'd have the connect, but change the function (onClick in our case) to function(