Messaging Service not always replicating to other servers

Currently i am trying to make custom servers that people can join and if you are in a different server then the colour of the part is different. for some reason when I test it, it doesn’t replicate but if i wait between every time i call the function then for some reason it does end up replicating. Does anyone know why this is happening? Here is the script:

game.ReplicatedStorage.SendMsg.OnServerEvent:Connect(function(player, Server)
	
	local messagingService = game:GetService("MessagingService")

	local connection

	function event()

		if Server == "Server1" then
			
			local nmp = Instance.new("MeshPart", workspace)
			nmp.Anchored = false
			
			nmp.Position = Vector3.new(0,2,0)
			
			local newattachment = Instance.new("Attachment", nmp)
			local newlv = Instance.new("LinearVelocity", newattachment)
			
			newlv.VectorVelocity = Vector3.new(0,1,0)
			
			newlv.MaxForce = math.huge
			newlv.Attachment0 = newattachment
			newlv.RelativeTo = "Attachment0"
			
			nmp.BrickColor = BrickColor.new("Bright violet")
			
		elseif Server == "Server2" then
			
			local nmp = Instance.new("MeshPart", workspace)
			nmp.Anchored = false
			
			nmp.Position = Vector3.new(0,2,0)

			local newattachment = Instance.new("Attachment", nmp)
			local newlv = Instance.new("LinearVelocity", newattachment)
			
			newlv.VectorVelocity = Vector3.new(0,1,0)

			newlv.MaxForce = math.huge
			newlv.Attachment0 = newattachment
			newlv.RelativeTo = "Attachment0"

			nmp.BrickColor = BrickColor.new("Bright violet")
			
		end
		
		connection:Disconnect()
		wait(10)
		establishConnection()

	end

	function establishConnection()
		connection = messagingService:SubscribeAsync("event", event)
	end

	establishConnection()
	
	messagingService:PublishAsync("event")
		
end)