Teleportation script not teleporting

Greetings! Below I have a script. The objective is to load the text, then after the text is loaded teleport the player to another game. I’ve asked multiple people, and they aren’t too sure as to whats wrong with it.

   local text = "Please wait.... loading systems then teleporting to application center"
for i = 1, #text do 
    script.Parent.animtext.Text = string.sub(text, 1, i)
    wait(0.05)
end
while true do

wait(10)
end
 text = "Systems Loaded! Teleporting to application center... please wait."
for i = 1, #text do 
script.Parent.text2.Text = string.sub(text, 1, i)
wait(0.05)
end

while true do
wait(0.01)
end
    while true do
    wait(0.01)
local TeleportService = game:GetService("TeleportService")

     function removeSpaces(str)
    local newStr = ""
for s in string.gmatch(str,"%S") do
    newStr = (newStr .. s)
       end
return newStr
end

game.Players.PlayerAdded:Connect(function(player)
TeleportService:Teleport(5003357963, player, removeSpaces(string.lower(script.ID.Value)))
end)
end

you have a random forever loop that stops the script in there

while true do
    wait(0.01)
end

this is stopping the script and forever looping this spot

1 Like

do i just delete it? (30characters)

First, like @trytry1 said, you have some random forever loops and 1 loop that doesn’t make any sense, if you don’t have any purpose other waiting for a few second after the text is loaded then just add a wait.

Second, PlayerAdded is fired when the player enter so I think it will just teleport you and not wait for the text to be finished.