Data across servers?

I’m working on a City with destroyable buildings. I was wondering if there were a way to replicate the Data across all servers - Allowing them to detect whether or not a building is destroyed?

I was thinking this would be DataStore?

2 Likes

MessagingService was introduced last year. Might wanna look into that. Whenever the building is destroyed just send a message to all servers.

2 Likes

Following on from this - Would I then need to implement a DataStore to save the Buildings that have been destroyed in new servers?

If you really wanted the building to permanently be destroyed, sure.

1 Like

Permanently destroy for a time-period prior tp regeneration.

I assume I could use MessagingService to Sync the countdowns until Regeneration?

Yes you can do that. Most of these questions have an answer of “if you want to”

I’m met with an error of: “Message router disconnected”.

    local System = {}
        	
    local MessagingService = game:GetService("MessagingService")
    local isDestroyable = game:GetService("Workspace"):WaitForChild("isDestroyable")
	
	function callbackFunction(serviceData)
	end
	
	for _,i in pairs (isDestroyable:GetChildren()) do
		spawn(function()
			wait(15)
			i["isHealth"].Value = 0
		end)
		local isHealth = i["isHealth"]
		isHealth.Changed:Connect(function(Value)
			if Value == 0 then
				MessagingService:PublishAsync("isBuilding", i.Name)
			end
		end)
	end
	
	MessagingService:SubscribeAsync("isBuilding", callbackFunction)
	
	return System

I would use Datastores since they can be updated across servers.