How to teleport players when a text is set to something?

I want to teleport all players when the text of a textlabel is “Teleporting” How do I do that?
I made this script but it doesn’t work

local Text = game.StarterGui.ScreenGui.Frame.StoryLine

if Text.Text == "Teleporting. . ." then
	game:GetService('TeleportService'):Teleport( 6895914089, game.Players.LocalPlayer) 
end

I don’t really remeber if that’s true but i think when you get the textlabel it’s saved in the state it was when you got it so if you update the text later then it wont detect it until you get the textlabel again after that.

1 Like

This cannot be done in a LocalScript, because it will only teleport the local player. To teleport all players:

local players = game.Players:GetPlayers()
for i, plr in pairs(players) do
    if plr then
        game:GetService("TeleportService"):Teleport(6895914089, plr) 
    end
end

Do this from a ServerScript. Alternately, if you wanted to only teleport the local player, then:

local Text = game.StarterGui.ScreenGui.Frame.StoryLine

game:GetService("RunService").RenderStepped:Connect(function()
    if Text.Text == "Teleporting. . ." then
        game:GetService('TeleportService'):Teleport(6895914089, game.Players.LocalPlayer)
    end
end
2 Likes