Code almost works

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the countdown gui to appear every time a player gets in the submarine

  2. What is the issue? Include screenshots / videos if possible!
    the first time a player gets in the submarine the gui appears but every other time it does not

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I don’t know what the problem is, and there are no errors, so I didn’t really look.

basically, it’s the Doors elevators, but they’re submarines instead of elevators.
everything works besides the gui getting cloned into the player’s PlayerGui the second time the player gets in the submarine.

the script:

local SubCount = script.Parent.BillBoardGuiPart.PlayersInSub
local GameID = 13034935080
local TeleportService = game:GetService("TeleportService")
local MinPlayerRequired = script.Parent.MinimumPlayersRequiredToStart
local SubName = script.Parent.NameOfSub
local PlayersInParty = {}
local ReadyToGo = script.Parent.ReadyToGo


SubCount.Changed:Connect(function(NewVar)				----- someone leave/joins
	if SubCount.Value >= MinPlayerRequired.Value then ------ if enough players are playing then
		for _,v in game.Players:GetChildren() do     -------- look at all of the players
			if v:FindFirstChild(SubName.Value).Value == true then --- find which sub they are in
				table.insert(PlayersInParty,v) ---- add them to the players playing
				ReadyToGo.Value = true		 --------- and start teleport seqince
			else -------------------------- all players not in sub
				if table.find(PlayersInParty,v) then  --- if they are on the list
					table.remove(PlayersInParty,v) --- they get removed
				end
				v:FindFirstChild(SubName.Value).Value = false --makes sure they are not in the sub
				if v.PlayerGui:FindFirstChild("TeleportCountdown") then --- if they have the gui 
					v.PlayerGui:FindFirstChild("TeleportCountdown"):Destroy() -- it's destroyed
				end
			end
		end
	end
end)


ReadyToGo.Changed:Connect(function(NewVar) ----when everythings ready
	if ReadyToGo.Value == true then --------------see above
		for _,v in PlayersInParty do --------- everyone on the list
			local Gui = game.ReplicatedStorage.Guis.TeleportCountdown:Clone() --- gets a
			Gui.Parent = v.PlayerGui --------------------------------------------gui
			if 	v:FindFirstChild(SubName.Value).Value == false then ---- if they change their minds
				table.remove(PlayersInParty,v) ---------------------they are removed from the list
				v.PlayerGui:FindFirstChild("TeleportCountdown"):Destroy() --- and the gui is destroyed
			end
		end
		wait(10) --------- after 10 seconds
		for _,v in PlayersInParty do ------ get all players on the list
			if v:FindFirstChild(SubName.Value).Value == true then ---and they are sure
				TeleportService:TeleportPartyAsync(13034935080, PlayersInParty) -- they teleport
			else ---------------if they are unsure then
				if v.PlayerGui:FindFirstChild("TeleportCountdown") then --the gui is destroyed
					v.PlayerGui.TeleportCountdown:Destroy()----------------see above
				end
			end
	end
	end
end)

I’ve never really delt with teleporting and barely use tables but I’m pretty sure I did everything right, unfortunately I obviously did not because it doesn’t work lol.

sorry if this is a particularly stupid question, and thanks for helping!
unless you didn’t help

My question is, why are you destroying the teleport countdown GUI? Can’t you just set Enabled to false?

if I had the teleport countdown GUI in the player’s PlayerGui then it will start the countdown without it being enabled. but when I clone it all the players in the submarine will have a synchronized countdown. and I destroy it so it will be synchronized when the player gets back in the submarine.

Ok, So I edited the script a little because I noticed that the countdown wouldn’t be synchronized across all players. so here’s what it looks like now:

local SubCount = script.Parent.BillBoardGuiPart.PlayersInSub
local GameID = 13034935080
local TeleportService = game:GetService("TeleportService")
local MinPlayerRequired = script.Parent.MinimumPlayersRequiredToStart
local SubName = script.Parent.NameOfSub
local PlayersInParty = {}
local ReadyToGo = script.Parent.ReadyToGo


SubCount.Changed:Connect(function(NewVar)				----- someone leave/joins
	if SubCount.Value >= MinPlayerRequired.Value then ------ if enough players are playing then
		for _,v in game.Players:GetChildren() do     -------- look at all of the players
			if v:FindFirstChild(SubName.Value).Value == true then --- find which sub they are in
				table.insert(PlayersInParty,v) ---- add them to the players playing
				ReadyToGo.Value = true		 --------- and start teleport seqince
			else -------------------------- all players not in sub
				if table.find(PlayersInParty,v) then  --- if they are on the list
					table.remove(PlayersInParty,v) --- they get removed
				end
				v:FindFirstChild(SubName.Value).Value = false --makes sure they are not in the sub
				if v.PlayerGui:FindFirstChild("TeleportCountdown") then --- if they have the gui 
					v.PlayerGui:FindFirstChild("TeleportCountdown"):Destroy() -- it's destroyed
				end
			end
		end
	end
end)


ReadyToGo.Changed:Connect(function(NewVar) ----when everythings ready
	if ReadyToGo.Value == true then --------------see above
		for _,v in PlayersInParty do --------- everyone on the list
			local Gui = game.ReplicatedStorage.Guis.TeleportCountdown:Clone() --- gets a
			Gui.Parent = v.PlayerGui --------------------------------------------gui
			if 	v:FindFirstChild(SubName.Value).Value == false then ---- if they change their minds
				table.remove(PlayersInParty,v) ---------------------they are removed from the list
				v.PlayerGui:FindFirstChild("TeleportCountdown"):Destroy() --- and the gui is destroyed
			end
		end
		
		
		local Time = 10
		local Value = script.Parent.DiveTime
		while Time ~= 0 do
			wait(1) --------- after 10 seconds
			Time -= 1
			Value.Value = Time
		end

		for _,v in PlayersInParty do ------ get all players on the list
			if v:FindFirstChild(SubName.Value).Value == true then ---and they are sure
				TeleportService:TeleportPartyAsync(13034935080, PlayersInParty) -- they dive
			else ---------------if they are unsure then
				if v.PlayerGui:FindFirstChild("TeleportCountdown") then --the gui is destroyed
					v.PlayerGui.TeleportCountdown:Destroy()----------------see above
				end
			end
	end
	end
end)

lol I solved the problem.

so first the problem was I never set ReadyToGo to false, I only ever set it to true

then the problem was the MinPlayerRequired value was set to 0 so when a player joined there was 1 person in the sub, and when the player left, there was 0 people in the sub, and 0 = 0 so it was never set to false.

sorry for not checking that value and thanks for your help!