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

How do I make a script so that when I chat something I get teleported?

Asked by 2 years ago

I was wondering, how do I make a script where if a specific player types something in chat, only the player who wrote the "message" in chat will be teleported to a part that I have already positioned in a specific area within the game?

1 answer

Log in to vote
0
Answered by 2 years ago

Hi There!

Before you can think of doing this, you need to know about the following:

TeleportService

And

Teleport

Now, we can get to the scripting part.

MAKE SURE YOU ENABLE 3RD PARTY TELEPORT SERVICE INSIDE OF SECURITY!!

So first, you can only teleport players to another Experience you own.

Place the following script in ServerScriptService:

local TeleportService = game:GetService("TeleportService")
local AllowedUsersToTeleport = {game.CreatorId,""} -- Add the users you want to teleport, username or userid.

local TARGET_PLACE_ID = 1818 -- The Target Place ID, It must be owned by you!

game.Players.PlayerAdded:Connect(function(player)
    for i,v in pairs(AllowedUsersToTeleport) do
        if player.Name == v or player.UserId == v then
            player.Chatted:Connect(function(message)
                local Text = "Your message here" -- Do not use spaces and make it completely lowercase elsewise it might break.
                if message == Text then
                    TeleportService:TeleportAsync(TARGET_PLACE_ID, player)
                    if error then
                        print(error())
                        return error
                    end
                end
            end)
        end
    end
end)
0
I think Ghostinee is trying to ask how to make a script that teleports you within the same game, not to a different place. boredlake 256 — 2y
Ad

Answer this question