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

How to teleport players when they chat something?

I tried to make one, but it didn't work. So I came to ask for help, and here you guys are. So how do you make 2 players, like if you would say "Duel/", then type in a players name how would you make both players teleport to that area ON CLICK?

2 answers

✓ Accepted answer
commands = {
	"duel/"
}
pos1 = Vector3.new(0,0,0) -- Where you want the chatter to go
pos2 = Vector3.new(0,0,0) -- Where you want the other person to go

game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		for i=1, #commands do
			if msg == string.lower(string.sub(commands[i], 1, string.len(commands[i]))) then
				if game.Players:findFirstChild(string.gsub(msg, commands[i], "")) then
					player.Character.Torso.CFrame = CFrame.new(pos1)
					game.Players[string.gsub(msg, commands[i], "")].Character.Torso.CFrame = CFrame.new(pos2)
				end
			end
		end
	end)
end)

Edit: Added in the teleportation stuff.

Edit2: @Hippalectryon Oops, your right. Forgot to add .Torso

Edit3: Sorry, I haven't used teleportation very much.

5 comments

1

Forwarded from Hippalectryon: "@the answer before mine (i can't post comments so i'll say it here) You wrote player.Character.Position = pos1 Isn't player.Character a model ? If so, models don't have a Position property do they ?"

0

Also, Hippalectryon noted you should either use the MoveTo method or change the CFrame of the torso as setting the Position of the Torso kills the user.

0

Didn't work...

0

Well... Output?

0

Never mind. You just want us to make a game for you. Source: http://www.roblox.com/Sword-Dueling-place?id=67150303

I'm adding to the above answer, you can achieve teleportation by CFraming the Torso as-well as using MoveTo, the chat method can be seen in the above answer. Example:

game.Workspace.Owenrules12.Torso.CFrame = game.Workspace.Part.CFrame
OR

game.Workspace.Owenrules12.Torso.CFrame = CFrame.new(5,5,5) -- X,Y,Z

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