FireAllClients not working

I have made a server script which uses the FireAllClients() and it seems to never be received by the .OnClientEvent in the PlayerGUI. I am supposed to transmit a table from a server script to a local script but it never seems to be reached by the local script. I have tried everything and I hope you guys can help. This is my script for the Local Script:

local mapui = game.ReplicatedStorage:WaitForChild("MAPUI")
function changeUIS(mapchosen)
	print(mapchosen)

end
mapui.OnClientEvent:Connect(changeUIS)

ServerScript:

local mapchosen = {1,2,3}
local mapui = game.ReplicatedStorage:WaitForChild("MAPUI")
mapui:FireAllClients(mapchosen)

That is because FireAllClients fire before the Player even joins in this context. You can test this out by adding this line of code before you call FireAllClients:

print(game:GetService("Players"):GetPlayers())

In normal situations, you won’t have to worry about it since it is unlikely you are firing the RemoteEvent before anyone is in the server anyways.

I have added scripts before the FireAllClients has been fired. Maybe is there another way to transport tables other than through firing the RemoteEvent that I could try?

Put this on server script

local mapchosen = {1,2,3}
local mapui = game.ReplicatedStorage:WaitForChild("MAPUI")

game.Players.PlayerAdded:Connect(function()
	mapui:FireAllClients(mapchosen)
end)