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

Teleport on chat keyword script not working?

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

✓ Accepted answer

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)

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