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

Teleport on chat keyword script not working?

Asked by 3 years ago

I'm using a script in server script storage that is meant to teleport a player to a separate place when they say a keyword in chat but when I test it (in Roblox, not studio) it never works. When I test it in the studio it says "Teleport Invalid", can someone please tell me how to fix this?

local TeleportService = game:GetService("TeleportService")
TeleportService:Teleport(gameid)

game.Players.PlayerAdded:Connect(function(player) 
    player.Chatted:Connect(function(msg) 
        if msg == "Yessir" then
            game:GetService('TeleportService'):Teleport(GameID) 
        end
    end)
end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

you have to put the player variable in like this :

local TeleportService = game:GetService("TeleportService")
    TeleportService:Teleport(gameid)

    game.Players.PlayerAdded:Connect(function(player)
        player.Chatted:Connect(function(msg)
            if msg == "Yessir" then
                game:GetService('TeleportService'):Teleport(GameID,player)
            end
        end)
    end)

Ad

Answer this question