Script only affecting one person

Hello,

I made a script for a Elevator Game and its only affecting one person even when they both have the Playing Value as true. Can anyone help? (It is a ServerScriptService script and not a LocalScript)

local mapCount = 4
while true do
	wait(10)
	local TweenService = game:GetService("TweenService")

	local part = game.Workspace.ElevatorShaft.DoorPart1
	local part2 = game.Workspace.ElevatorShaft.DoorPart2
--Closed
	local goal1 = {}
	goal1.Position = Vector3.new(-4.451, 6.5, -206)

	local goal2 = {}
	goal2.Position = Vector3.new(-4.451, 6.5, -200)
-- Open
	local goal3 = {}
	goal3.Position = Vector3.new(-4.451, 6.5, -210)

	local goal4 = {}
	goal4.Position = Vector3.new(-4.451, 6.5, -196)


	local tweenInfo = TweenInfo.new(3)

	local tween1Close = TweenService:Create(part, tweenInfo, goal1)
	local tween2Close = TweenService:Create(part2, tweenInfo, goal2)
	local tween1Open = TweenService:Create(part, tweenInfo, goal3)
	local tween2Open = TweenService:Create(part2, tweenInfo, goal4)
	
	tween1Open:Play()
	tween2Open:Play()
	game.Workspace.ElevatorShaft.BarrierPart.CanCollide = false
	for i,v in  pairs (game.Workspace.Map:GetChildren()) do
		if v then
			v:Destroy()
		end
	end
	for i,v in pairs (game.Workspace.Music:GetChildren()) do
		if v then
			v:Stop()
		end
	end
	local newMap = math.random(1,mapCount)
	local map = game.ReplicatedStorage.Levels[newMap]:Clone()
	map.Parent = workspace.Map
	if newMap == 1 then
		game.Workspace.Music.FastSpeed:Play()
		for i,v in pairs(game.Players:GetPlayers()) do
			if v.PlayerStats.Playing.Value == true then



				v.Character.Humanoid.WalkSpeed = 160

				task.wait(20)

				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame

				game.Workspace.Music.FastSpeed:Stop()

				tween1Close:Play()
				tween2Close:Play()

				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true

				map:Destroy()
				task.wait(3)
			end
		end
	end
	if newMap == 2 then
		for i,v in pairs(game.Players:GetChildren()) do
			if v.PlayerStats.Playing.Value == true then
				
				game.Workspace.Music.Lasers:Play()

				wait(20)
				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
				game.Workspace.Music.Lasers:Stop()
				tween1Close:Play()
				tween2Close:Play()
				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
				wait(3)
				map:Destroy()

			end






		end
	end
	
	if newMap == 3 then
		game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
		for i,v in pairs(game.Players:GetChildren()) do
			if v.PlayerStats.Playing.Value == true then

				game.Workspace.Music.High:Play()
				

				wait(10)
				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
				game.Workspace.Music.High:Stop()
				tween1Close:Play()
				tween2Close:Play()
				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
				wait(3)
				map:Destroy()
				

			end






		end
	end

	if newMap == 4 then
		
		for i,v in pairs(game.Players:GetChildren()) do
			if v.PlayerStats.Playing.Value == true then

				game.Workspace.Music.RainingTacos:Play()


				wait(20)
				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
				game.Workspace.Music.RainingTacos:Stop()
				tween1Close:Play()
				tween2Close:Play()
				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
				wait(3)
				map:Destroy()


			end






		end
	end




end

I assume the issue occurs due to the waits in your code, apparently the code waits 23 seconds before running for each player, therefore looking like it only runs for one of them. Instead you should look into a different approach where the loop runs inside that code part instead of the opposite, example:

--old
for i,v in pairs(game.Players:GetPlayers()) do
	if v.PlayerStats.Playing.Value == true then
		v.Character.Humanoid.WalkSpeed = 160
		task.wait(20)
		v.Character.Humanoid.WalkSpeed = 16
		v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
		game.Workspace.Music.FastSpeed:Stop()
		tween1Close:Play()
		tween2Close:Play()
		game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
		map:Destroy()
		task.wait(3)
	end
end

--new 
local Players = game:GetService("Players")

--functions outside of the while true do loop
function setWalkspeedForPlaying(walkspeed)
	for _, v in pairs(Players:GetPlayers()) do 
		if not v.PlayerStats.Playing.Value then continue end 	
		v.Character.Humanoid.WalkSpeed = walkspeed 
	end
end

function teleportPlaying(cf)
	for _, v in pairs(Players:GetPlayers()) do 
		if not v.PlayerStats.Playing.Value then continue end 	
		v.Character.HumanoidRootPart.CFrame = cf  
	end
end

--replace old with:
setWalkspeedForPlaying(160)
task.wait(20)
setWalkspeedForPlaying(16)
teleportPlaying(workspace.ElevatorShaft.TeleportPart.CFrame)
workspace.Music.FastSpeed:Stop()
tween1Close:Play()
tween2Close:Play()
workspace.ElevatorShaft.BarrierPart.CanCollide = true
map:Destroy()
task.wait(3)

It works! Thank you very much!