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

How can I make a teleporter that only tps one person?

Hi. I am making a hotel game and my hotel doesn't have room for a real moving elevator. I built an elevator box under the map and I was hoping that there was a way that I could tp only one person. Here is the code I have now. It teleports everybody in the game when you click it. Thats why I am here: ~~~~~~~~~~~~~~~~~

function onClicked()

local c = game.Players:GetChildren() for i = 1, #c do c[i].Character.UpperTorso.CFrame = CFrame.new(script.Parent.Parent.Teleport1.Position)--change "teleport1" to the name of the object you want to be teled to... end

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Can you help please? It tps everyone in the game to it and we often get stuck in walls. This script is in the button that tps to the inside of the elevator. So its like there is an elevator door with a button beside it. When you click the button it teleports you to the inner elevator.

1 comment

0

Use a Touched:Connect script instead

2 answers

You're calling :GetChildren() which can get more than 1 child so it teleports everyone.

And don't just use free model code and bring it here! because you don't code it how you want it to be.

Replace that with this:

script.Parent.ClickDetector.MouseClick:Connect(function(player) -- another way for function
	-- stuff(Use the 'player' thing too.)
end) -- close with a ')'

Whoever clicks it gets teleported but not everyone gets teleported at once.

2 comments

0

I used free model code because Im a scripting noob.

0

Where do I put it in the script? I'm sorry I barely know anything about lua.

Let me fix this script for you.

local objectname = "Teleport1" -- Change this to what it teleports you to.
script.Parent.ClickDetector.MouseClick:connect(function(player)

player.Character:MoveTo(script.Parent.Parent[objectname].Position)
end)

Hope this helped. Remember, Free models often have lag viruses that "infect" your game making it lag and spread everywhere! To prevent this either get my cleaner plugin or don't use free models ;)

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