Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to teleport players when they chat something?

Asked by 10 years ago

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

Log in to vote
2
Answered by 10 years ago
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.

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 ?" User#2 0 — 10y
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. User#2 0 — 10y
0
Didn't work... Lem0nzz 5 — 10y
0
Well... Output? PiggyJingles 358 — 10y
0
Never mind. You just want us to make a game for you. Source: http://www.roblox.com/Sword-Dueling-place?id=67150303 PiggyJingles 358 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

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

Answer this question