How to modify a global variable for ALL Servers with dev products

I was asked to make a global countdown for an event and now I’m confused as how to change the time when someone purchases + or - time, so basically a copy of this game: The Final Countdown In this game you can purchase time to increment and decrease time to the global count and Im confused how to do, here is the code I have so far:

local stopTime = 0

local startTime = 1730683364
local updateTime = game:GetService("ReplicatedStorage"):WaitForChild("UpdateTime")

while task.wait(1) do
	local currentTime = os.time()
	
	local timeLeft = startTime - currentTime
	
	local DaysLeft = math.floor((timeLeft / 60 / 60 / 24) % (365 + 0.2425))
	local HoursLeft = math.floor((timeLeft / 60 / 60) % 24) 
	local MinutesLeft = math.floor((timeLeft / 60) % 60) 
	local SecondsLeft = math.floor(timeLeft % 60) 
	
	if currentTime >= startTime then
		
	else
		updateTime:FireAllClients(DaysLeft, HoursLeft, MinutesLeft, SecondsLeft, timeLeft)
	end
end
1 Like

Use a datastore --min characters required

1 Like

bump pls someone help - 30alallala

datastores and messaging service basically whenever someone updates the timer u get updated time and set it to the datastore for the servers which will boot up when players join and arent currently active and fire an event with the updated time through the messaging service for the existing servers which subscribe to the said event and update their time accordingly

This system is quite complex but you can make it using:
Messaging Service - when in a server someone made a purchase, it sends request to all other servers so they can update the timer.
DataStoreService - Use it to store the purchased/updated time so when a new server starts, simply gets the async, subtracts the updated time from the passed time and boom!
ProxyServer? - You can use third party service to store whether the purchased time or better the time itself.

I hope this helps! If you have any questions or I have a mistake, feel free to reply! :smiley:

Yeah actually, I’ve never used messaging service and I was actually told to use MemoryStoreService which is just NOT working in the slightest. Basically Im using profileservice to capture all the ID’s of the devproducts which are like increase1, increase2, decrease1, decrease2 etc. and then after that I have no idea how to modify the actual value of the time because I don’t know where to store the variable local startTime = 1730683364, which is the end date. Would I store it in each players data, and then update to each player when someone buys?

also in my for loop for the actual counter how am I going to change each players timer, since I cannot obtain the player from the while loop, the startTime variable would have to be global and not a value in the players here is the code i cannot figure out:

while task.wait(1) do
	print("RUNN")
	local currentTime = os.time()
	
	local timeLeft = startTime - currentTime -- I DONT KNOW WHAT TO DO HERE
	
	print(globalTime)
	
	local DaysLeft = math.floor((timeLeft / 60 / 60 / 24) % (365 + 0.2425))
	local HoursLeft = math.floor((timeLeft / 60 / 60) % 24) 
	local MinutesLeft = math.floor((timeLeft / 60) % 60) 
	local SecondsLeft = math.floor(timeLeft % 60) 
	
	if currentTime >= startTime then
		
	else
		updateTime:FireAllClients(DaysLeft, HoursLeft, MinutesLeft, SecondsLeft, timeLeft)
	end--]]
end

Another note is that I have a table of all the ID’s like I said but how can I obtain the players startTime value from the while loop?? Here is the SETTINGS table for the devproducts:

local SETTINGS = {
	
	
	StartingSeconds = {
		Increased = 0,
		Decreased = 0,
		startTime = 1730683364
	},
	
	
	Products = {
		[2472101755] = function(profile)
			profile.Data.Increased += 25
			profile.Data.startTime += 25
		end,
		
		[2472106415] = function(profile)
			profile.Data.Increased += 100
			profile.Data.startTime += 100
		end,
		
		[2472115238] = function(profile)
			profile.Data.Increased += 300
			profile.Data.startTime += 300
		end,
		
		[2472119822] = function(profile)
			profile.Data.Increased += 600
			profile.Data.startTime += 600
		end,
		
		[2472125669] = function(profile)
			profile.Data.Increased += 1500
			profile.Data.startTime += 1500
		end,
		
		[2472132196] = function(profile)
			profile.Data.Increased += 3000
			profile.Data.startTime += 3000
		end,
		
		[2472142197] = function(profile)
			profile.Data.Increased += 18000
			profile.Data.startTime += 18000
		end,
		
		[2472151759] = function(profile)
			profile.Data.Increased += 180000
			profile.Data.startTime += 180000
		end,
		
		[2472158993] = function(profile)
			profile.Data.Increased += 432000
			profile.Data.startTime += 432000
		end,
		
		[2471670746] = function(profile)
			profile.Data.Increased -= 10
			profile.Data.startTime -= 10
		end,

		[2471679653] = function(profile)
			profile.Data.Increased -= 40
			profile.Data.startTime -= 40
		end,

		[2471687269] = function(profile)
			profile.Data.Increased -= 120
			profile.Data.startTime -= 120
		end,

		[2471697038] = function(profile)
			profile.Data.Increased -= 240
			profile.Data.startTime -= 240
		end,

		[2471706809] = function(profile)
			profile.Data.Increased -= 600
			profile.Data.startTime -= 600
		end,

		[2471729978] = function(profile)
			profile.Data.Increased -= 1200
			profile.Data.startTime -= 1200
		end,

		[2471744372] = function(profile)
			profile.Data.Increased -= 7200
			profile.Data.startTime -= 7200
		end,

		[2471760329] = function(profile)
			profile.Data.Increased -= 72000
			profile.Data.startTime -= 72000
		end,

		[2471771714] = function(profile)
			profile.Data.Decreased -= 172800
			profile.Data.startTime -= 172800
		end,
	},
	
	
	PurchaseIdLog = 50,
}