Why isn't the while true loop working?

ok, i recently just ran into a completely random thing, without no explanation, no errors in the output, out of nowhere. this while true loop stopped working, i tested that fact by printing a " loop started " if it did, but it just didn’t. is this roblox or is it just something wrong in my code?

The Script

local mapfolder = game.Lighting.Maps
local maps = mapfolder:GetChildren()
local roundtime = script.RoundTime
local musicFolder = game.Lighting.Music
local particlesFolder = game.Lighting.Particles
local lastmap
local particles
while true do
	local chosenmap = maps[math.random(1,#maps)]
	if chosenmap == lastmap then 
		repeat chosenmap = maps[math.random(1,#maps)] until chosenmap ~= lastmap
	end
	local currentmap = chosenmap:Clone()
	currentmap.Parent = game.Workspace
	currentmap:MakeJoints()
	local music = musicFolder[chosenmap.Name]:Clone()
	music.Parent = workspace
	music:Play()
	if particlesFolder:FindFirstChild(chosenmap.Name) ~= nil then
		particles = particlesFolder[chosenmap.Name:GetChildren()]:Clone()
		particles.Parent = workspace
	end
	for i,player in pairs(game:GetService("Players"):GetPlayers()) do
		player:LoadCharacter()
	end
	wait(300)
	lastmap = chosenmap
	currentmap:Destroy()
	music:Destroy()
	particles:Destroy()
end

thanks for reading, please help!

2 Likes

is this a script in server script service?

2 Likes

no, but while true loops work everywhere?

i’ve used them in local scripts
it’s in starterplayer, and it’s a regular script

1 Like

you are wait(300) maybe that? i think of printing

2 Likes

it should have printed the loop was running before the wait 300

i found the reason, the folder the script was in accidently got moved to starterplayer

1 Like