Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do sub-places in a game connect?

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)

1 answer

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(

2 comments

0

My original script freezes my game in the middle of the teleportation. But I tried defining the teleporting player like you said, and nothing much happened. Looks like I learned something new today about shortening scripts, at least. Thanks

0

Your welcome, and sorry I can't be of any help...

This discussion is preserved as it was. New answers, comments, and votes are closed.