How to update the map across all servers?

Hi there,

I would like to have a map in my game that can be edited by players and have those edits show up across all servers. Is there a relatively simple way to do this? I’ve looked into the MessagingService but can’t entirely wrap my head around it…

Thanks,
gargondoid

1 Like

There isn’t any other way, as far as I know. Obviously, you have to communicate with all the servers in the game. The only way to communicate with other servers is through the MessagingService.

Maybe you could possibly use a DataStore, however the DataStoreService has many restrictions preventing you from creating a smooth experience in this case and isn’t supposed to be used in that way.

2 Likes

You can use RemoteFunctions to accomplish this. Here is a quick example.
Server Script
local Map = {}

– This function will be called by the client and will change the Map.
local function SetMap(key, value)
Map[key] = value
end
– Register it as a remote function that only runs on the server.
game.ReplicatedStorage.SetMap.OnServerInvoke = SetMap

– This function will be called by the client and will return the value of the specified key in the Map.
local function GetMap(key)
return Map[key]
end
– Register it as a remote function that runs on the client and the server.
game.ReplicatedStorage.GetMap.OnServerInvoke = GetMap
game.ReplicatedStorage.GetMap.OnClientInvoke = GetMap

Client Script
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild(“Humanoid”)
humanoid.Died:Connect(function()
– Call the remote function SetMap with the arguments: “Character”, character
game.ReplicatedStorage.SetMap:InvokeServer(“Character”, character)
end)
end)
end)

1 Like